Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-3686

Test Failure - Mypy tests failing (avoid using stub file for codec options namedtuple generic workaround)

    • Type: Icon: Build Failure Build Failure
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 4.4
    • Affects Version/s: None
    • Component/s: Tests, Typing
    • None

      Mypy tests started failing last week:

        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
      
      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>=35.0.0 in /opt/hostedtoolcache/Python/3.7.16/x64/lib/python3.7/site-packages (from types-pyOpenSSL) (40.0.2)
      Collecting types-urllib3<1.27 (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.7.16/x64/lib/python3.7/site-packages (from cryptography>=35.0.0->types-pyOpenSSL) (1.15.1)
      Requirement already satisfied: pycparser in /opt/hostedtoolcache/Python/3.7.16/x64/lib/python3.7/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.28.11.17 types-urllib3-1.26.25.10
      Installing missing stub packages:
      /opt/hostedtoolcache/Python/3.7.16/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: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[_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:1118: 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:1212: 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:1351: 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:1351: 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:1351: 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.
      

      Here's the install dependencies logs:

      Run python -m pip install -U pip mypy==0.990
        python -m pip install -U pip mypy==0.990
        pip install -e ".[zstd, encryption, ocsp]"
        shell: /usr/bin/bash -e {0}
        env:
          pythonLocation: /opt/hostedtoolcache/Python/3.7.16/x64
          LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.7.16/x64/lib
      Requirement already satisfied: pip in /opt/hostedtoolcache/Python/3.7.16/x64/lib/python3.7/site-packages (22.0.4)
      Collecting pip
        Downloading pip-23.1.1-py3-none-any.whl (2.1 MB)
           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 18.3 MB/s eta 0:00:00
      Collecting mypy==0.990
        Downloading mypy-0.990-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (15.5 MB)
           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 15.5/15.5 MB 83.0 MB/s eta 0:00:00
      Collecting typing-extensions>=3.10 (from mypy==0.990)
        Downloading typing_extensions-4.5.0-py3-none-any.whl (27 kB)
      Collecting mypy-extensions>=0.4.3 (from mypy==0.990)
        Downloading mypy_extensions-1.0.0-py3-none-any.whl (4.7 kB)
      Collecting tomli>=1.1.0 (from mypy==0.990)
        Downloading tomli-2.0.1-py3-none-any.whl (12 kB)
      Collecting typed-ast<2,>=1.4.0 (from mypy==0.990)
        Downloading typed_ast-1.5.4-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (843 kB)
           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 843.7/843.7 kB 78.4 MB/s eta 0:00:00
      Installing collected packages: typing-extensions, typed-ast, tomli, pip, mypy-extensions, mypy
        Attempting uninstall: pip
          Found existing installation: pip 22.0.4
          Uninstalling pip-22.0.4:
            Successfully uninstalled pip-22.0.4
      Successfully installed mypy-0.990 mypy-extensions-1.0.0 pip-23.1.1 tomli-2.0.1 typed-ast-1.5.4 typing-extensions-4.5.0
      Obtaining file:///home/runner/work/mongo-python-driver/mongo-python-driver
        Installing build dependencies: started
        Installing build dependencies: finished with status 'done'
        Checking if build backend supports build_editable: started
        Checking if build backend supports build_editable: finished with status 'done'
        Getting requirements to build editable: started
        Getting requirements to build editable: finished with status 'done'
        Preparing editable metadata (pyproject.toml): started
        Preparing editable metadata (pyproject.toml): finished with status 'done'
      Collecting dnspython<3.0.0,>=1.16.0 (from pymongo==4.4.0.dev1)
        Downloading dnspython-2.3.0-py3-none-any.whl (283 kB)
           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 283.7/283.7 kB 5.8 MB/s eta 0:00:00
      Collecting pymongocrypt<2.0.0,>=1.5.0 (from pymongo==4.4.0.dev1)
        Downloading pymongocrypt-1.5.2-py2.py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (5.0 MB)
           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.0/5.0 MB 95.7 MB/s eta 0:00:00
      Collecting pymongo-auth-aws<2.0.0 (from pymongo==4.4.0.dev1)
        Downloading pymongo_auth_aws-1.1.0-py2.py3-none-any.whl (11 kB)
      Collecting pyopenssl>=17.2.0 (from pymongo==4.4.0.dev1)
        Downloading pyOpenSSL-23.1.1-py3-none-any.whl (57 kB)
           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 57.9/57.9 kB 21.1 MB/s eta 0:00:00
      Collecting requests<3.0.0 (from pymongo==4.4.0.dev1)
        Downloading requests-2.28.2-py3-none-any.whl (62 kB)
           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.8/62.8 kB 20.8 MB/s eta 0:00:00
      Collecting service-identity>=18.1.0 (from pymongo==4.4.0.dev1)
        Downloading service_identity-21.1.0-py2.py3-none-any.whl (12 kB)
      Collecting zstandard (from pymongo==4.4.0.dev1)
        Downloading zstandard-0.21.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB)
           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.7/2.7 MB 94.3 MB/s eta 0:00:00
      Collecting boto3 (from pymongo-auth-aws<2.0.0->pymongo==4.4.0.dev1)
        Downloading boto3-1.26.118-py3-none-any.whl (135 kB)
           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 135.6/135.6 kB 40.0 MB/s eta 0:00:00
      Collecting botocore (from pymongo-auth-aws<2.0.0->pymongo==4.4.0.dev1)
        Downloading botocore-1.29.118-py3-none-any.whl (10.7 MB)
           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.7/10.7 MB 67.4 MB/s eta 0:00:00
      Collecting cffi<2,>=1.12.0 (from pymongocrypt<2.0.0,>=1.5.0->pymongo==4.4.0.dev1)
        Downloading cffi-1.15.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (427 kB)
           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 427.9/427.9 kB 71.0 MB/s eta 0:00:00
      Collecting cryptography>=2.0 (from pymongocrypt<2.0.0,>=1.5.0->pymongo==4.4.0.dev1)
        Downloading cryptography-40.0.2-cp36-abi3-manylinux_2_28_x86_64.whl (3.7 MB)
           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.7/3.7 MB 102.2 MB/s eta 0:00:00
      Collecting charset-normalizer<4,>=2 (from requests<3.0.0->pymongo==4.4.0.dev1)
        Downloading charset_normalizer-3.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (171 kB)
           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 171.0/171.0 kB 46.1 MB/s eta 0:00:00
      Collecting idna<4,>=2.5 (from requests<3.0.0->pymongo==4.4.0.dev1)
        Downloading idna-3.4-py3-none-any.whl (61 kB)
           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.5/61.5 kB 24.4 MB/s eta 0:00:00
      Collecting urllib3<1.27,>=1.21.1 (from requests<3.0.0->pymongo==4.4.0.dev1)
        Downloading urllib3-1.26.15-py2.py3-none-any.whl (140 kB)
           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 140.9/140.9 kB 42.5 MB/s eta 0:00:00
      Collecting certifi>=2017.4.17 (from requests<3.0.0->pymongo==4.4.0.dev1)
        Downloading certifi-2022.12.7-py3-none-any.whl (155 kB)
           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 155.3/155.3 kB 47.1 MB/s eta 0:00:00
      Collecting attrs>=19.1.0 (from service-identity>=18.1.0->pymongo==4.4.0.dev1)
        Downloading attrs-23.1.0-py3-none-any.whl (61 kB)
           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.2/61.2 kB 20.6 MB/s eta 0:00:00
      Collecting pyasn1-modules (from service-identity>=18.1.0->pymongo==4.4.0.dev1)
        Downloading pyasn1_modules-0.3.0-py2.py3-none-any.whl (181 kB)
           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 181.3/181.3 kB 50.2 MB/s eta 0:00:00
      Collecting pyasn1 (from service-identity>=18.1.0->pymongo==4.4.0.dev1)
        Downloading pyasn1-0.5.0-py2.py3-none-any.whl (83 kB)
           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 83.9/83.9 kB 30.4 MB/s eta 0:00:00
      Collecting six (from service-identity>=18.1.0->pymongo==4.4.0.dev1)
        Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
      Collecting importlib-metadata (from attrs>=19.1.0->service-identity>=18.1.0->pymongo==4.4.0.dev1)
        Downloading importlib_metadata-6.6.0-py3-none-any.whl (22 kB)
      Collecting pycparser (from cffi<2,>=1.12.0->pymongocrypt<2.0.0,>=1.5.0->pymongo==4.4.0.dev1)
        Downloading pycparser-2.21-py2.py3-none-any.whl (118 kB)
           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 118.7/118.7 kB 36.7 MB/s eta 0:00:00
      Collecting jmespath<2.0.0,>=0.7.1 (from boto3->pymongo-auth-aws<2.0.0->pymongo==4.4.0.dev1)
        Downloading jmespath-1.0.1-py3-none-any.whl (20 kB)
      Collecting s3transfer<0.7.0,>=0.6.0 (from boto3->pymongo-auth-aws<2.0.0->pymongo==4.4.0.dev1)
        Downloading s3transfer-0.6.0-py3-none-any.whl (79 kB)
           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 79.6/79.6 kB 24.4 MB/s eta 0:00:00
      Collecting python-dateutil<3.0.0,>=2.1 (from botocore->pymongo-auth-aws<2.0.0->pymongo==4.4.0.dev1)
        Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 247.7/247.7 kB 63.3 MB/s eta 0:00:00
      Collecting zipp>=0.5 (from importlib-metadata->attrs>=19.1.0->service-identity>=18.1.0->pymongo==4.4.0.dev1)
        Downloading zipp-3.15.0-py3-none-any.whl (6.8 kB)
      Requirement already satisfied: typing-extensions>=3.6.4 in /opt/hostedtoolcache/Python/3.7.16/x64/lib/python3.7/site-packages (from importlib-metadata->attrs>=19.1.0->service-identity>=18.1.0->pymongo==4.4.0.dev1) (4.5.0)
      Building wheels for collected packages: pymongo
        Building editable for pymongo (pyproject.toml): started
        Building editable for pymongo (pyproject.toml): finished with status 'done'
        Created wheel for pymongo: filename=pymongo-4.4.0.dev1-0.editable-cp37-cp37m-linux_x86_64.whl size=9595 sha256=acbf790d11e718ed01dda876b20ffadf631a02dad3b1d3383ef1699ff1b1b52b
        Stored in directory: /tmp/pip-ephem-wheel-cache-bo_rt6pq/wheels/35/24/ce/e739ae13e7c85b414c4ea1546eacd8b0a6ec093da1c28f7d66
      Successfully built pymongo
      Installing collected packages: zstandard, zipp, urllib3, six, pycparser, pyasn1, jmespath, idna, dnspython, charset-normalizer, certifi, requests, python-dateutil, pymongo, pyasn1-modules, importlib-metadata, cffi, cryptography, botocore, attrs, service-identity, s3transfer, pyopenssl, pymongocrypt, boto3, pymongo-auth-aws
      Successfully installed attrs-23.1.0 boto3-1.26.118 botocore-1.29.118 certifi-2022.12.7 cffi-1.15.1 charset-normalizer-3.1.0 cryptography-40.0.2 dnspython-2.3.0 idna-3.4 importlib-metadata-6.6.0 jmespath-1.0.1 pyasn1-0.5.0 pyasn1-modules-0.3.0 pycparser-2.21 pymongo-4.4.0.dev1 pymongo-auth-aws-1.1.0 pymongocrypt-1.5.2 pyopenssl-23.1.1 python-dateutil-2.8.2 requests-2.28.2 s3transfer-0.6.0 service-identity-21.1.0 six-1.16.0 urllib3-1.26.15 zipp-3.15.0 zstandard-0.21.0
      

      https://github.com/mongodb/mongo-python-driver/actions/runs/4774438795/jobs/8488116577

            Assignee:
            steve.silvester@mongodb.com Steve Silvester
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: