-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add annotations and py.typed to conform with PEP561 #31
Conversation
This is great, thanks for the hard work. Could you please squash your commits ? @gaborbernat since you have the most experience on this, I'd like to hear your comments on this. |
Could you please capitalise the commit and add a description of what it does ? Helps with the docs... |
@erikseulean made a few changes. lemme know if they work? |
setup.cfg
Outdated
@@ -1,2 +1,12 @@ | |||
[bdist_wheel] | |||
universal = true | |||
|
|||
[mypy] | |||
python_version = 3.7 |
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 should be not set here as we need to run against both python 2 and 3, given we support both.
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.
can remove this. we'd have to set two different runs in tox then, one for each version
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.
yeah, can do that in tox.ini as separate commands one after another
attrs_strict/__init__.pyi
Outdated
@@ -0,0 +1,2 @@ | |||
from ._error import AttributeTypeError as AttributeTypeError, BadTypeError as BadTypeError, TupleError as TupleError, TypeValidationError as TypeValidationError, UnionError as UnionError |
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.
we need some tool that validates that content from the python file matches with the stubs; for example https://pypi.org/project/retype/ is an example, please use it in our tox check... see https://github.com/ambv/retype/blob/master/tox.ini#L58
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.
wasn't aware of this. will add!
This will need rebase. |
39b3bd3
to
372a361
Compare
* Black format Signed-off-by: Erik-Cristian Seulean <[email protected]> * Fix handling of typing.Any So far Any was not taken in consideration and it was failing to handle it correctly. If the base_type is Any, stop the recursive check and return as if everything is fine. Signed-off-by: Erik-Cristian Seulean <[email protected]> Signed-off-by: Wilfred Wong <[email protected]>
This would enable custom made types that extend collections.abc.Mapping and collections.abc.MutableMapping Signed-off-by: Erik-Cristian Seulean <[email protected]> Signed-off-by: Wilfred Wong <[email protected]>
Signed-off-by: Wilfred Wong <[email protected]>
typing.NewType is actual just a function and should be interpreted as an alias for something. However its __str__ ‘NewType.<locals>.new_type’, so it includes neither its custom name nor the type for which it is an alias, which is not very helpful to identify why a certain type check failed. Hence, such information are also printed in error messages, but other types are left as they were before. Signed-off-by: Fabian Raab <[email protected]> Signed-off-by: Wilfred Wong <[email protected]>
Fixes: bloomberg#35 Signed-off-by: Siddhant Kumar <[email protected]> Signed-off-by: Wilfred Wong <[email protected]>
…berg#38) Closes bloomberg#37 Signed-off-by: David Douard <[email protected]> Signed-off-by: Wilfred Wong <[email protected]>
Signed-off-by: Siddhant Kumar <[email protected]> Signed-off-by: Wilfred Wong <[email protected]>
Signed-off-by: Wilfred Wong <[email protected]> mypy --strict. add MANIFEST.in. run tox on both python versions Signed-off-by: Wilfred Wong <[email protected]> rework type annotations as necessary Signed-off-by: Wilfred Wong <[email protected]>
*Issue number of the reported bug or feature request: #24
Describe your changes
made
attrs-strict
PEP561 compatible by adding annotations andpy.typed
. This removes the missing import error frommypy
when attempting to run static type checking on packages usingattrs-strict
Testing performed
Was able to successfully run static type checking in a test project after installing attrs-strict from my branch.
when testing on a separate library:
Additional context
could use some extra attention on how this was added to tox to make sure it was done correctly
future changes to
attrs_strict
will need to ensure the stubs are updated appropriately as this will not come for free as long as we need to support python 2