5

pip_api: type hints by woodruffw · Pull Request #97 · di/pip-api · GitHub

 2 years ago
source link: https://github.com/di/pip-api/pull/97
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Copy link

Contributor

Author

woodruffw commented on Sep 13, 2021

edited

Turns out that this is a significant pain due to the vendored modules:

$ mypy pip_api
pip_api/_vendor/pyparsing.py:123: error: Module "itertools" has no attribute "ifilterfalse"; maybe "filterfalse"?
pip_api/_vendor/pyparsing.py:123: error: Name "filterfalse" already defined (possibly by an import)
pip_api/_vendor/pyparsing.py:126: error: Module "_thread" has no attribute "RLock"
pip_api/_vendor/pyparsing.py:143: error: Cannot find implementation or library stub for module named "ordereddict"
pip_api/_vendor/pyparsing.py:143: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
pip_api/_vendor/pyparsing.py:143: error: Name "_OrderedDict" already defined (possibly by an import)
pip_api/_vendor/pyparsing.py:145: error: Cannot assign to a type
pip_api/_vendor/pyparsing.py:145: error: Incompatible types in assignment (expression has type "None", variable has type "Type[OrderedDict[Any, Any]]")
pip_api/_vendor/pyparsing.py:150: error: Name "SimpleNamespace" already defined (possibly by an import)
pip_api/_vendor/pyparsing.py:233: error: Module has no attribute "maxint"
pip_api/_vendor/pyparsing.py:234: error: Name "xrange" is not defined
pip_api/_vendor/pyparsing.py:236: error: Name "_ustr" already defined on line 227
pip_api/_vendor/pyparsing.py:260: error: Cannot find implementation or library stub for module named "__builtin__"
pip_api/_vendor/pyparsing.py:1800: error: Name "_FifoCache" already defined on line 1771
pip_api/_vendor/pyparsing.py:1829: error: Need type annotation for "packrat_cache" (hint: "packrat_cache: Dict[<type>, <type>] = ...")
pip_api/_vendor/pyparsing.py:2902: error: "Type[ParserElement]" has no attribute "_literalStringClass"
pip_api/_vendor/pyparsing.py:5086: error: Not all arguments converted during string formatting
pip_api/_vendor/pyparsing.py:5944: error: "Callable[[VarArg(Any), KwArg(Any)], Any]" has no attribute "ANY_VALUE"
pip_api/_vendor/pyparsing.py:6730: error: Need type annotation for "_ranges" (hint: "_ranges: List[<type>] = ...")
pip_api/_vendor/pyparsing.py:6799: error: Need type annotation for "_ranges" (hint: "_ranges: List[<type>] = ...")
Found 19 errors in 1 file (checked 21 source files)

The CI will pass above, but the parent call to mypy in pip-audit will continue to fail because of these inner errors. I've tried to mark the imports for pyparsing with # type: ignore, but that doesn't seem to have done anything...

Edit: I've added mypy to the CI to (hopefully) demonstrate the failure.


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK