-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
Mypy app-wide scope #786
Mypy app-wide scope #786
Conversation
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.
LGTM
a couple of small proposals
if isinstance(some_user, User): | ||
users.append(some_user) | ||
else: | ||
users += some_user | ||
assert len( |
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.
could it be:
users: list[User] = [some_user] if isintance(some_user, User) else some_users
BTW i would rather keep the var name users
because it is simpler?
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.
Yes that works too, that's actually a good use of variable shadowing
Thanks, ready for me |
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.
Hey, @why-not-try-calmer @faebebin . Thanks for the contribution and reviews.
There are a couple of problems that from this PR, the worst of them in docker-app/qfieldcloud/subscription/models.py line 815 -> the assert there is changing the behaviour of the app, therefore breaking it.
I caught this error when trying to integrate this PR changes with web UI.
I would suggest for such quite fundamental changes we have a double review, cool down period and opening a PR on the web ui to verify the changes are working.
See #791 for the fixes.
'Organization "{}" cannot be added. Only users and teams can be collaborators.' | ||
).format(username), | ||
message = _( | ||
f'Organization "{username}" cannot be added. Only users and teams can be collaborators.' |
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.
I have already commented this in another place, this replacing "{}".format(1)
with f"{1}"
is causing troubles for potential translations.
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.
Fixed.
@@ -794,7 +794,7 @@ def create_subscription( | |||
plan: Plan, | |||
created_by: Person, | |||
active_since: Optional[datetime] = None, | |||
) -> Tuple["Subscription", "Subscription"]: | |||
) -> tuple[Optional["AbstractSubscription"], "AbstractSubscription"]: |
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.
Why don't you use the definition from the docs: tuple[AbstractSubscription | None, AbstractSubscription]
?
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.
Fixed.
@@ -794,7 +794,7 @@ def create_subscription( | |||
plan: Plan, | |||
created_by: Person, | |||
active_since: Optional[datetime] = None, |
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.
This one should be datetime | None
as all other places, no?
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.
Fixed.
assert active_since | ||
|
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.
This assert is actually breaking the system, as we have situations where we DO allow no active since to be passed. You can clearly see that from the typing of the function argument.
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.
Fixed.
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.
thanks for fixing 👍
I merged this quite early after only 1 approval so it's on me. I think it makes sense indeed to let you / the project owner do the merges for anything non-trivial, especially when several pending PRs can impact each other. |
This extends the scope of the static type-checker to also encompass docker-app and docker-redis.