typedb / typedb-driver-python

TypeDB Driver for Python

Home Page:https://typedb.com

Repository from Github https://github.comtypedb/typedb-driver-pythonRepository from Github https://github.comtypedb/typedb-driver-python

Add 'as_X' methods to Concept and its subtypes

alexjpwalker opened this issue · comments

Problem to Solve

Since introducing type hinting, I've noticed that it isn't always terribly helpful to the user.

PyCharm seems to believe that if you specify that a method

def get(var: str) -> Concept:
    pass

returns Concept, then that means it returns exactly Concept, and not any subclass of Concept.

Proposed Solution

For the concept package specifically, we could fix this issue by introducing the asX casting methods that we have in client-java. Sure, types are dynamic so it feels a little silly, perhaps heavy-handed: but I think it may be the right thing to do, and it also adds consistency with client-java.

We should then ensure that we use those methods where they are applicable throughout the codebase.

These were added earlier this year.