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

#86dtb6tt0 - Change the usage of typing collections to use collections.abc and update the tests accordingly #1247

Merged
merged 1 commit into from
May 6, 2024

Conversation

meevee98
Copy link
Collaborator

@meevee98 meevee98 commented May 6, 2024

Summary or solution description
Refactor all usages of classes from collection.abc that were imported from typing.
Also removed all from __future__ import annotations that could be replaced by the typing.Self annotation

…ions.abc` and update the tests accordingly
@meevee98 meevee98 self-assigned this May 6, 2024
@melanke
Copy link
Collaborator

melanke commented May 6, 2024

@coveralls
Copy link
Collaborator

Coverage Status

coverage: 91.759% (-0.01%) from 91.773%
when pulling 8c8575f on CU-86dtb6tt0
into 44bc501 on development.

Copy link
Collaborator

@luc10921 luc10921 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use "{ClassName}" instead of Self on boa3/internal/model/type/classes/classtype.py and boa3/internal/model/type/itype.py?

bases: list["ClassType"] = None):

def union_type(self, other_type: "IType") -> "IType":

@meevee98
Copy link
Collaborator Author

meevee98 commented May 6, 2024

Why use "{ClassName}" instead of Self on boa3/internal/model/type/classes/classtype.py and boa3/internal/model/type/itype.py?

bases: list["ClassType"] = None):

def union_type(self, other_type: "IType") -> "IType":

Quoting from Python typing docs:

You should not use Self as the return annotation if the method is not guaranteed to return an instance of a subclass when the class is subclassed.

That's the case on both cases above.
In the __init__ class of ClassType the base_class arg can be any subclass of ClassType, not *only* the self type.
The same for union_type class, it's not guaranteed that it will return the same type as the class is was called. (i.e.: Type.int.union_type(Type.str) won't return Type.int)
This is better described in PEP673

@luc10921 luc10921 merged commit 281fb49 into development May 6, 2024
5 checks passed
@luc10921 luc10921 deleted the CU-86dtb6tt0 branch May 6, 2024 21:01
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

Successfully merging this pull request may close these issues.

None yet

4 participants