-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
PYTHON-3679 Support mypy 1.2 #1194
Conversation
Not quite sure what's going on here but the mypy checks pass locally with 1.2:
Same versions of python and mypy fail in Actions: mypy --install-types --non-interactive bson gridfs tools pymongo
# Test overshadowed codec_options.py file
mypy --install-types --non-interactive bson/codec_options.py
mypy --install-types --non-interactive --disable-error-code var-annotated --disable-error-code attr-defined --disable-error-code union-attr --disable-error-code assignment --disable-error-code no-redef --disable-error-code index --allow-redefinition --allow-untyped-globals --exclude "test/mypy_fails/*.*" test
python -m pip install -U typing_extensions
mypy --install-types --non-interactive test/test_typing.py test/test_typing_strict.py
shell: /usr/bin/bash -e {0}
env:
pythonLocation: /opt/hostedtoolcache/Python/[3](https://github.com/mongodb/mongo-python-driver/actions/runs/4775556500/jobs/8489944286?pr=1194#step:5:3).10.11/x6[4](https://github.com/mongodb/mongo-python-driver/actions/runs/4775556500/jobs/8489944286?pr=1194#step:5:4)
LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.10.11/x64/lib
Collecting types-pyOpenSSL
Downloading types_pyOpenSSL-23.1.0.2-py3-none-any.whl (6.9 kB)
Collecting types-requests
Downloading types_requests-2.28.11.17-py3-none-any.whl (14 kB)
Requirement already satisfied: cryptography>=3[5](https://github.com/mongodb/mongo-python-driver/actions/runs/4775556500/jobs/8489944286?pr=1194#step:5:5).0.0 in /opt/hostedtoolcache/Python/3.10.11/x[6](https://github.com/mongodb/mongo-python-driver/actions/runs/4775556500/jobs/8489944286?pr=1194#step:5:6)4/lib/python3.10/site-packages (from types-pyOpenSSL) (40.0.2)
Collecting types-urllib3<1.2[7](https://github.com/mongodb/mongo-python-driver/actions/runs/4775556500/jobs/8489944286?pr=1194#step:5:7) (from types-requests)
Downloading types_urllib3-1.26.25.10-py3-none-any.whl (15 kB)
Requirement already satisfied: cffi>=1.12 in /opt/hostedtoolcache/Python/3.10.11/x64/lib/python3.10/site-packages (from cryptography>=35.0.0->types-pyOpenSSL) (1.15.1)
Requirement already satisfied: pycparser in /opt/hostedtoolcache/Python/3.10.11/x64/lib/python3.10/site-packages (from cffi>=1.12->cryptography>=35.0.0->types-pyOpenSSL) (2.21)
Installing collected packages: types-urllib3, types-requests, types-pyOpenSSL
Successfully installed types-pyOpenSSL-23.1.0.2 types-requests-2.2[8](https://github.com/mongodb/mongo-python-driver/actions/runs/4775556500/jobs/8489944286?pr=1194#step:5:8).11.17 types-urllib3-1.26.25.10
Installing missing stub packages:
/opt/hostedtoolcache/Python/3.10.11/x64/bin/python -m pip install types-pyOpenSSL types-requests
Success: no issues found in 84 source files
bson/__init__.py: note: In function "_get_object":
Found 13 errors in 1 file (checked 1 source file)
bson/__init__.py:302: error: Too many arguments for "Mapping" [call-arg]
return (opts.document_class(data[position : end + 1], opts), p...
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bson/__init__.py: note: In function "_bson_to_dict":
bson/__init__.py:5[9](https://github.com/mongodb/mongo-python-driver/actions/runs/4775556500/jobs/8489944286?pr=1194#step:5:9)9: error: Too many arguments for "Mapping" [call-arg]
return opts.document_class(data, opts)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bson/__init__.py: note: In function "decode":
bson/__init__.py:[10](https://github.com/mongodb/mongo-python-driver/actions/runs/4775556500/jobs/8489944286?pr=1194#step:5:10)19: error: "CodecOptions" expects no type arguments, but 1
given [type-arg]
data: "_ReadableBuffer", codec_options: "Optional[CodecOptions[_Do...
^
bson/__init__.py:1020: error: A function returning TypeVar should receive at
least one argument containing the same TypeVar [type-var]
) -> "_DocumentType":
^
bson/__init__.py:1020: note: Consider using the upper bound "Mapping[str, Any]" instead
bson/__init__.py: note: In function "_decode_all":
bson/__init__.py:1054: error: "CodecOptions" expects no type arguments, but 1
given [type-arg]
data: "_ReadableBuffer", opts: "CodecOptions[_DocumentType]"
^
bson/__init__.py: note: In function "decode_all":
bson/__init__.py:1090: error: "CodecOptions" expects no type arguments, but 1
given [type-arg]
data: "_ReadableBuffer", codec_options: "Optional[CodecOptions[_Do...
^
bson/__init__.py: note: At top level:
bson/__init__.py:[11](https://github.com/mongodb/mongo-python-driver/actions/runs/4775556500/jobs/8489944286?pr=1194#step:5:11)18: error: Unused "type: ignore" comment
return _decode_all(data, opts) # type: ignore[arg-type]
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bson/__init__.py: note: In function "_decode_all_selective":
bson/__init__.py:[12](https://github.com/mongodb/mongo-python-driver/actions/runs/4775556500/jobs/8489944286?pr=1194#step:5:13)12: error: "CodecOptions" expects no type arguments, but 1
given [type-arg]
internal_codec_options: CodecOptions[RawBSONDocument] = codec_opti...
^
bson/__init__.py: note: In function "decode_iter":
bson/__init__.py:1226: error: "CodecOptions" expects no type arguments, but 1
given [type-arg]
data: bytes, codec_options: "Optional[CodecOptions[_DocumentType]]...
^
bson/__init__.py: note: In function "decode_file_iter":
bson/__init__.py:1262: error: "CodecOptions" expects no type arguments, but 1
given [type-arg]
... file_obj: Union[BinaryIO, IO], codec_options: "Optional[CodecOption...
^
bson/__init__.py: note: At top level:
bson/__init__.py:[13](https://github.com/mongodb/mongo-python-driver/actions/runs/4775556500/jobs/8489944286?pr=1194#step:5:14)51: error: Unused "type: ignore[assignment]" comment
def decode(self, codec_options: "CodecOptions[_DocumentType]" = DE...
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~...
bson/__init__.py: note: In member "decode" of class "BSON":
bson/__init__.py:1[35](https://github.com/mongodb/mongo-python-driver/actions/runs/4775556500/jobs/8489944286?pr=1194#step:5:36)1: error: "CodecOptions" expects no type arguments, but 1
given [type-arg]
def decode(self, codec_options: "CodecOptions[_DocumentType]" = DE...
^
bson/__init__.py:1351: note: Error code "type-arg" not covered by "type: ignore" comment
bson/__init__.py:1351: error: A function returning TypeVar should receive at
least one argument containing the same TypeVar [type-var]
...ions[_DocumentType]" = DEFAULT_CODEC_OPTIONS) -> "_DocumentType": # t...
^
bson/__init__.py:13[51](https://github.com/mongodb/mongo-python-driver/actions/runs/4775556500/jobs/8489944286?pr=1194#step:5:52): note: Error code "type-var" not covered by "type: ignore" comment
bson/__init__.py:1351: note: Consider using the upper bound "Mapping[str, Any]" instead
bson/__init__.py:1351: note: Error code "misc" not covered by "type: ignore" comment
Error: Process completed with exit code 1. |
I think one of the dependencies updated, since I saw similar errors in #1195 |
On Actions:
Locally:
Both using Python 3.10.11. |
Interestingly when I remove bson/codec_options.pyi, I get many of the same errors as above: $ rm bson/codec_options.pyi && mypy --install-types --non-interactive bson gridfs tools
bson/__init__.py: note: In function "_get_object":
bson/__init__.py:302: error: Too many arguments for "Mapping" [call-arg]
return (opts.document_class(data[position : end + 1], opts), position + obj_size)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bson/__init__.py: note: In function "_bson_to_dict":
bson/__init__.py:599: error: Too many arguments for "Mapping" [call-arg]
return opts.document_class(data, opts)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bson/__init__.py: note: In function "decode":
bson/__init__.py:1019: error: "CodecOptions" expects no type arguments, but 1 given [type-arg]
data: "_ReadableBuffer", codec_options: "Optional[CodecOptions[_DocumentType]]" = None
^
bson/__init__.py:1020: error: A function returning TypeVar should receive at least one argument containing the same TypeVar [type-var]
) -> "_DocumentType":
^
bson/__init__.py:1020: note: Consider using the upper bound "Mapping[str, Any]" instead
.... |
I'm going to open a new issue to track the CodecOptions issues. |
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!
PYTHON-3679 Fix Unused "type: ignore" comment PYTHON-3679 Fix bson/decimal128.py:103: error: Unsupported operand types for + ("Literal['n']" PYTHON-3679 Ignore bson/son.py:69: error: Value of type variable "Self" of "__new__" of "dict" cannot be "SON[_Key, _Value]" [type-var] PYTHON-3679 More fixes PYTHON-3679 Change cast to type: ignore PYTHON-3679 Remove unused import
5e076b7
to
67e5041
Compare
https://jira.mongodb.org/browse/PYTHON-3679
Adds workarounds/fixes for some small changes in:
typing_extensions.Self
in the stdlib python/typeshed#9694DecimalTuple
can have string exponent python/typeshed#9194