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

Support mypy --strict testing

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • 5.0
    • Affects Version/s: None
    • Component/s: Typing
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      mypy --strict testing was removed in PYTHON-3686:

            - name: Run mypy strict
              run: |
                mypy --strict test/test_typing_strict.py
      

      This currently fails with 2072 errors:

      Run mypy --strict test/test_typing_strict.py
        mypy --strict test/test_typing_strict.py
        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
      bson/__init__.py:119: note: In module imported here,
      pymongo/collection.py:106: note: ... from here,
      test/test_typing_strict.py:20: note: ... from here:
      bson/min_key.py: note: In member "__repr__" of class "MinKey":
      bson/min_key.py:53: error: Function is missing a type annotation 
      [no-untyped-def]
              def __repr__(self):
              ^
      bson/__init__.py:118: note: In module imported here,
      pymongo/collection.py:106: note: ... from here,
      test/test_typing_strict.py:20: note: ... from here:
      bson/max_key.py: note: In member "__repr__" of class "MaxKey":
      bson/max_key.py:53: error: Function is missing a type annotation 
      [no-untyped-def]
              def __repr__(self):
              ^
      pymongo/cursor.py:37: note: In module imported here,
      pymongo/collection.py:47: note: ... from here,
      test/test_typing_strict.py:20: note: ... from here:
      bson/code.py: note: In member "__repr__" of class "Code":
      bson/code.py:89: error: Function is missing a type annotation  [no-untyped-def]
              def __repr__(self):
              ^
      ....
      Found 2072 errors in 69 files (checked 1 source file)
      

      Steve noted that it's odd that mypy complains about errors in pymongo in this test when it should only be checking the one test/test_typing_strict.py test file itself. This was probably a change in mypy.

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

              Created:
              Updated: