-
Notifications
You must be signed in to change notification settings - Fork 46
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
[PT-5198] Workspace singleton #595
Conversation
up42/__init__.py
Outdated
get_webhooks, | ||
create_webhook, | ||
get_webhook_events, | ||
get_credits_balance, | ||
] | ||
if hasattr(obj, "__name__") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pylint is triggering an error if we do not add this. Alternative option is to set an ignore. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It means something is off, otherwise we would get the warning before as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some research, I finally found what is off here.
We have changed the authenticate
variable to store the method of a Class. It seems that before mypy
was able to infer that there were Classes
, and functions
in the comprenhensive list and all of them have the __name__
property. Now, for some reason (perhaps the new typing, or some update of mypy
that has changed since the latest commit that touch the init.py file) mypy
is not able to do the same type infer than before.
Since the list contains a mix of classes, functions, and now the new authentication
variable. mypy
infers the most general type that can accommodate all elements, which is likely object
. The object type in Python doesn't have a name attribute, leading to the error.
I figure out that splitting the assingment for Classes, and functions makes mypy
happy and infers correctly the type.
I also tested this and it works as well:
__all__ = [
Asset.__name__,
Auth.__name__,
Catalog.__name__,
Order.__name__,
Storage.__name__,
Tasking.__name__,
Webhook.__name__,
get_example_aoi.__name__,
read_vector_file.__name__,
initialize_catalog.__name__,
initialize_tasking.__name__,
initialize_storage.__name__,
initialize_order.__name__,
initialize_asset.__name__,
initialize_webhook.__name__,
authenticate.__name__,
get_webhooks.__name__,
create_webhook.__name__,
get_webhook_events.__name__,
get_credits_balance.__name__,
]
We can think of a cleaner solution, perharps assigning authenticate
to a better type. I did some tests but I ended up splitting the assignment of the all property into Classes
and functions
.
…54_WorkspaceMixin
@@ -39,9 +39,9 @@ class Storage: | |||
``` | |||
""" | |||
|
|||
def __init__(self, auth: up42_auth.Auth): | |||
def __init__(self, auth: up42_auth.Auth, workspace_id: str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a breaking change?
I ask because I see the version bumped was set to patch version instead of minor.
|
Described Here
Adding workspace mixing to implement active record pattern
Items:
For release: