Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate overloads for queriable commands #11

Open
Muream opened this issue Feb 1, 2023 · 3 comments
Open

Generate overloads for queriable commands #11

Muream opened this issue Feb 1, 2023 · 3 comments

Comments

@Muream
Copy link
Owner

Muream commented Feb 1, 2023

Most likely there would be one overload per flag where the flag type becomes a bool and the return type becomes the initial flag type

Essentially, this:

def addAttr(arg0: str, longName: str = ..., attributeType: str = ..., minValue: float = ...) -> None:
    ...

Would become this:

def addAttr(arg0: str, longName: str = ..., attributeType: str = ..., minValue: float = ...) -> None:
    ...

@overload
def addAttr(arg0: str, query: bool, longName: bool) -> str:
    ...

@overload
def addAttr(arg0: str, query: bool, attributeType: bool) -> str:
    ...

@overload
def addAttr(arg0: str, query: bool, minValue: bool) -> float:
    ...

Note that the query flag isn't in the non overloaded function definition

@willemkokke
Copy link

These would have to be doubled up for q=True, unless you are only accepting the long form query=True

@Muream
Copy link
Owner Author

Muream commented Feb 1, 2023

Yeah, I'm only including longname arguments in the stubs, those short names are the death of me haha

@Muream
Copy link
Owner Author

Muream commented Feb 1, 2023

Just realized this might be trickier than this as some commands allow for multiple flags to be queried at the same time and there doesn't seem to be any consistent way to know that programmatically

One example is

def xform(*args: str, query: bool, translation: bool) -> [float, float float]: ...
def xform(*args: str, query: bool, translation: bool, worldSpace: bool) -> [float, float float]: ...

Ignoring this edge case for now might still be better than not having overloads at all though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants