Repository navigation
[WIP] mypy updates - #111
[WIP] mypy updates #111manu-chroma wants to merge 55 commits into
Conversation
|
Changes made: 420ea14 ~/github/schema_salad · (mypy_updates±) $ tox -e py35-mypy 17:20:26
py35-mypy recreate: /home/manu/github/schema_salad/.tox/py35-mypy
py35-mypy installdeps: mypy==0.511, typed-ast==1.0.3, -rrequirements.txt
py35-mypy installed: appdirs==1.4.3,avro-python3==1.8.2,CacheControl==0.11.7,certifi==2017.4.17,chardet==3.0.3,idna==2.5,isodate==0.5.4,lockfile==0.12.2,mistune==0.7.3,mypy==0.511,packaging==16.8,pkg-resources==0.0.0,pyparsing==2.2.0,rdflib==4.2.2,rdflib-jsonld==0.4.0,requests==2.16.5,ruamel.yaml==0.14.0,six==1.10.0,typed-ast==1.0.3,typing==3.5.3.0,urllib3==1.21.1
py35-mypy runtests: PYTHONHASHSEED='2432188320'
py35-mypy runtests: commands[0] | make mypy
rm -Rf typeshed/2.7/ruamel/yaml
ln -s /home/manu/github/schema_salad/.tox/py35-mypy/lib/python3.5/site-packages/ruamel/yaml \
typeshed/2.7/ruamel/
MYPYPATH=typeshed/2.7 mypy --py2 --disallow-untyped-calls \
--warn-redundant-casts --warn-unused-ignores \
schema_salad
typeshed/2.7/ruamel/yaml/compat.py:15: error: Cannot find module named 'ruamel.ordereddict'
typeshed/2.7/ruamel/yaml/compat.py:15: note: (Perhaps setting MYPYPATH or using the "--ignore-missing-imports" flag would help)
typeshed/2.7/ruamel/yaml/compat.py:15: error: Name 'ordereddict' already defined
typeshed/2.7/ruamel/yaml/reader.py:199: error: None not callable
typeshed/2.7/ruamel/yaml/reader.py:205: error: "UnicodeDecodeError" has no attribute "object"
typeshed/2.7/ruamel/yaml/reader.py:205: error: "UnicodeDecodeError" has no attribute "start"
typeshed/2.7/ruamel/yaml/reader.py:208: error: "UnicodeDecodeError" has no attribute "start"
typeshed/2.7/ruamel/yaml/reader.py:211: error: "UnicodeDecodeError" has no attribute "start"
typeshed/2.7/ruamel/yaml/reader.py:213: error: "UnicodeDecodeError" has no attribute "start"
typeshed/2.7/ruamel/yaml/reader.py:215: error: "UnicodeDecodeError" has no attribute "encoding"
typeshed/2.7/ruamel/yaml/reader.py:215: error: "UnicodeDecodeError" has no attribute "reason"
typeshed/2.7/ruamel/yaml/comments.py:281: error: "CommentedBase" has no attribute "_yaml_get_column"; maybe "_yaml_get_pre_comment"?
typeshed/2.7/ruamel/yaml/representer.py:522: error: Incompatible types in assignment (expression has type "Union[Any, Dict[Any, Any]]", target has type List[Any])
schema_salad/schema.py:434: error: Type argument 1 of "make_valid_avro" has incompatible value "Union[Any, Dict[Any, Any], unicode]"
schema_salad/ref_resolver.py:75: note: unused 'type: ignore' comment
schema_salad/ref_resolver.py:81: note: unused 'type: ignore' comment
schema_salad/ref_resolver.py:84: note: unused 'type: ignore' comment
schema_salad/ref_resolver.py:809: note: unused 'type: ignore' comment
schema_salad/ref_resolver.py:847: note: unused 'type: ignore' comment
schema_salad/ref_resolver.py:1003: note: unused 'type: ignore' comment
schema_salad/schema.py:181: note: unused 'type: ignore' comment
schema_salad/validate.py:216: note: unused 'type: ignore' comment
Makefile:173: recipe for target 'mypy' failed
make: *** [mypy] Error 1
ERROR: InvocationError: '/usr/bin/make mypy'
__________________________________________________________________________________________________________________ summary ___________________________________________________________________________________________________________________
ERROR: py35-mypy: commands failed@AleksandrSl Also, I wanted to know how can you help out in improving |
|
@manu-chroma Maybe errors are due to the version of typeshed, it's 2.7 and tests were for 3.5 |
|
@AleksandrSl |
|
Hey @AleksandrSl
we're running mypy with
whatever possible. 😄 I'll keep this PR updated and soon begin with python3 mypy work. |
|
@mr-c, Can you help me out with these errors? 😄 Almost all of them are related to ruamel package. (venv) [venv] ~/github/schema_salad · (mypy_updates±) $ tox -e py35-mypy 13:16:35
py35-mypy installed: appdirs==1.4.3,avro-python3==1.8.2,CacheControl==0.11.7,certifi==2017.4.17,chardet==3.0.3,idna==2.5,isodate==0.5.4,lockfile==0.12.2,mistune==0.7.3,mypy==0.511,packaging==16.8,pyparsing==2.2.0,rdflib==4.2.2,rdflib-jsonld==0.4.0,requests==2.17.3,ruamel.yaml==0.14.0,six==1.10.0,typed-ast==1.0.3,typing==3.5.3.0,urllib3==1.21.1
py35-mypy runtests: PYTHONHASHSEED='4041677850'
py35-mypy runtests: commands[0] | make mypy
rm -Rf typeshed/2.7/ruamel/yaml
ln -s /home/manu/github/schema_salad/.tox/py35-mypy/lib/python3.5/site-packages/ruamel/yaml \
typeshed/2.7/ruamel/
MYPYPATH=typeshed/2.7 mypy --py2 --disallow-untyped-calls \
--warn-redundant-casts --warn-unused-ignores \
schema_salad
typeshed/2.7/ruamel/yaml/compat.py:15: error: Cannot find module named 'ruamel.ordereddict'
typeshed/2.7/ruamel/yaml/compat.py:15: note: (Perhaps setting MYPYPATH or using the "--ignore-missing-imports" flag would help)
typeshed/2.7/ruamel/yaml/compat.py:15: error: Name 'ordereddict' already defined
typeshed/2.7/ruamel/yaml/reader.py:199: error: None not callable
typeshed/2.7/ruamel/yaml/reader.py:205: error: "UnicodeDecodeError" has no attribute "object"
typeshed/2.7/ruamel/yaml/reader.py:205: error: "UnicodeDecodeError" has no attribute "start"
typeshed/2.7/ruamel/yaml/reader.py:208: error: "UnicodeDecodeError" has no attribute "start"
typeshed/2.7/ruamel/yaml/reader.py:211: error: "UnicodeDecodeError" has no attribute "start"
typeshed/2.7/ruamel/yaml/reader.py:213: error: "UnicodeDecodeError" has no attribute "start"
typeshed/2.7/ruamel/yaml/reader.py:215: error: "UnicodeDecodeError" has no attribute "encoding"
typeshed/2.7/ruamel/yaml/reader.py:215: error: "UnicodeDecodeError" has no attribute "reason"
typeshed/2.7/ruamel/yaml/comments.py:281: error: "CommentedBase" has no attribute "_yaml_get_column"; maybe "_yaml_get_pre_comment"?
typeshed/2.7/ruamel/yaml/representer.py:522: error: Incompatible types in assignment (expression has type "Union[Any, Dict[Any, Any]]", target has type List[Any])
Makefile:169: recipe for target 'mypy' failed
make: *** [mypy] Error 1
ERROR: InvocationError: '/usr/bin/make mypy'
__________________________________________________________________________________________________________________ summary ___________________________________________________________________________________________________________________
ERROR: py35-mypy: commands failed |
|
@manu-chroma Error |
|
Thanks @AleksandrSl , you are correct. Ideally @manu-chroma Is there a way to have |
|
@mr-c Commenting directory removal and symlink creation in Makefile will help with ruamel |
|
So these errors didn't come up because |
|
@manu-chroma |
|
@AleksandrSl I am surprised to hear that -- since |
|
@mr-c I think that my solution is just a trick, not a real one. If these lines are commented it seems that ruamel package is not checked at all, but i don't see better way to get rid of these errors. Maybe additional typeshed for ruamel that will correct inconsistencies inside ruamel annotations can help. |
|
I would like to point out that I'm using
I also think this might be the case. |
|
Tried using venv) [venv] ~/github/schema_salad · (mypy_updates±) $ tox -e py35-mypy 19:20:05
py35-mypy installed: appdirs==1.4.3,avro-python3==1.8.2,CacheControl==0.11.7,certifi==2017.4.17,chardet==3.0.3,idna==2.5,isodate==0.5.4,lockfile==0.12.2,mistune==0.7.3,mypy==0.511,packaging==16.8,pyparsing==2.2.0,rdflib==4.2.2,rdflib-jsonld==0.4.0,requests==2.17.3,ruamel.yaml==0.14.0,six==1.10.0,typed-ast==1.0.3,typing==3.5.3.0,urllib3==1.21.1
py35-mypy runtests: PYTHONHASHSEED='1735989360'
py35-mypy runtests: commands[0] | make mypy
rm -Rf typeshed/2.7/ruamel/yaml
# ln -s /home/manu/github/schema_salad/.tox/py35-mypy/lib/python3.5/site-packages/ruamel/yaml \
# typeshed/2.7/ruamel/
MYPYPATH=typeshed/2.7 mypy --py2 --disallow-untyped-calls \
--warn-redundant-casts --warn-unused-ignores \
--warn-unused-ignores \
schema_salad
schema_salad/tests/test_examples.py:10: error: Cannot find module named 'ruamel.yaml'
schema_salad/tests/test_examples.py:10: note: (Perhaps setting MYPYPATH or using the "--ignore-missing-imports" flag would help)
schema_salad/tests/test_examples.py:20: error: Cannot find module named 'ruamel.yaml.comments'
schema_salad/tests/test_fetch.py:9: error: Cannot find module named 'ruamel.yaml'
schema_salad/jsonld_context.py:9: error: Cannot find module named 'ruamel.yaml'
schema_salad/ref_resolver.py:26: error: Cannot find module named 'ruamel.yaml'
schema_salad/ref_resolver.py:27: error: Cannot find module named 'ruamel.yaml.comments'
schema_salad/schema.py:8: error: Cannot find module named 'ruamel.yaml'
schema_salad/schema.py:31: error: Cannot find module named 'ruamel.yaml.comments'
schema_salad/sourceline.py:2: error: Cannot find module named 'ruamel.yaml'
schema_salad/sourceline.py:3: error: Cannot find module named 'ruamel.yaml.comments'
schema_salad/sourceline.py:13: error: Name 'ruamel.yaml.comments.CommentedBase' is not defined
schema_salad/sourceline.py:14: error: Module has no attribute "yaml"
schema_salad/sourceline.py:29: error: Name 'ruamel.yaml.comments.CommentedBase' is not defined
schema_salad/sourceline.py:91: error: Some element of union has no attribute "lc"
schema_salad/sourceline.py:92: error: Argument 1 to "iteritems" has incompatible type "Union[int, float, str, unicode, Dict[Any, Any], List[Any]]"; expected Mapping[Any, Any]
schema_salad/sourceline.py:93: error: Some element of union has no attribute "lc"
schema_salad/sourceline.py:94: error: Unsupported target for indexed assignment
schema_salad/sourceline.py:94: error: Some element of union has no attribute "lc"
schema_salad/sourceline.py:96: error: Unsupported target for indexed assignment
schema_salad/sourceline.py:99: error: Some element of union has no attribute "lc"
schema_salad/sourceline.py:100: error: Argument 1 to "enumerate" has incompatible type "Union[int, float, str, unicode, Dict[Any, Any], List[Any]]"; expected Iterable[Any]
schema_salad/sourceline.py:101: error: Some element of union has no attribute "lc"
schema_salad/sourceline.py:102: error: Unsupported target for indexed assignment
schema_salad/sourceline.py:102: error: Some element of union has no attribute "lc"
schema_salad/sourceline.py:104: error: Unsupported target for indexed assignment
schema_salad/sourceline.py:165: error: Module has no attribute "yaml"
schema_salad/ref_resolver.py:524: error: No overload variant of "__getitem__" of "unicode" matches argument types [builtins.unicode]
schema_salad/ref_resolver.py:1005: error: Dict[unicode, Union[Dict[Any, Any], unicode, Iterable[unicode]]] has no attribute "lc"
schema_salad/ref_resolver.py:1006: error: Dict[unicode, Union[Dict[Any, Any], unicode, Iterable[unicode]]] has no attribute "lc"
schema_salad/schema.py:240: error: No overload variant of "__getitem__" of "unicode" matches argument types [builtins.str]
schema_salad/schema.py:242: error: No overload variant of "__getitem__" of "unicode" matches argument types [builtins.str]
schema_salad/schema.py:289: error: List[Dict[unicode, Any]] has no attribute "lc"
schema_salad/schema.py:289: error: Some element of union has no attribute "lc"
schema_salad/schema.py:290: error: List[Dict[unicode, Any]] has no attribute "lc"
schema_salad/schema.py:290: error: Some element of union has no attribute "lc"
schema_salad/tests/test_examples.py:18: note: unused 'type: ignore' comment
schema_salad/jsonld_context.py:13: note: unused 'type: ignore' comment
Makefile:169: recipe for target 'mypy' failed
make: *** [mypy] Error 1
ERROR: InvocationError: '/usr/bin/make mypy'We're using classes from |
|
Note: I do nod recommend commenting out the |
|
@mr-c Just trying out the possibilities. 😄 So, when using I'll try to find other ways to selectively suppress warnings from ruamel package. |
|
@manu-chroma I have added typeshed for mistune - |
|
@AleksandrSl this looks great! I will try it out. 😃 If you're able to get permission from the |
|
@AleksandrSl I've replaced |
|
@manu-chroma I have raised an issue about ruamel errors https://bitbucket.org/ruamel/yaml/issues/123/update-type-annotations#comment-37387564 |
|
Next step would be to run without the |
@AleksandrSl This would definitely help. In the meantime, I've ignored ruamel errors by adding it in |
|
@manu-chroma @mr-c Some errors were fixed in ruamel: fix commit, issue |
|
I've gone through the fix commit. It's mostly using |
Main changes: - use of __future__ - using six lib to: - deal with checking unicode - dict operations - other API changes
- also, re-ogranise six lib imports
- use update ruamel.yaml package which includes more mypy annotations
author = "Aleksandr Slepchenkov" email = "[email protected]"
…in py3 mode and move to typshed/2and3/ directory
f464338 to
669ebfc
Compare
|
changes from here are now incorporated in #109 The purpose of this branch was to separately track mypy progress. Closing it now. |
Created this PR to discuss mypy related improvements in detail
Typesheds status