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

fix access to last_write_date

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 4.5
    • Affects Version/s: None
    • Component/s: None
    • None

      error and traceback:

      typecheck-mypy: install_deps> python -I -m pip install 'certifi; platform_system == "win32" or platform_system == "Darwin"' mypy==1.2.0 typing_extensions
      .pkg: install_requires> python -I -m pip install 'setuptools>=63.0'
      .pkg: _optional_hooks> python /opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/pyproject_api/_backend.py True setuptools.build_meta
      .pkg: get_requires_for_build_sdist> python /opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/pyproject_api/_backend.py True setuptools.build_meta
      .pkg: freeze> python -m pip freeze --all
      .pkg: pip==23.1.2,setuptools==67.8.0,wheel==0.40.0
      .pkg: build_sdist> python /opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/pyproject_api/_backend.py True setuptools.build_meta
      typecheck-mypy: install_package_deps> python -I -m pip install 'certifi; os_name == "nt" or sys_platform == "darwin"' 'dnspython<3.0.0,>=1.16.0' 'pymongo-auth-aws<2.0.0' 'pymongocrypt<2.0.0,>=1.6.0' 'pyopenssl>=17.2.0' 'requests<3.0.0' 'service_identity>=18.1.0' zstandard
      typecheck-mypy: install_package> python -I -m pip install --force-reinstall --no-deps /home/runner/work/mongo-python-driver/mongo-python-driver/.tox/.tmp/package/1/pymongo-4.5.0.dev0.tar.gz
      typecheck-mypy: freeze> python -m pip freeze --all
      typecheck-mypy: attrs==23.1.0,boto3==1.26.162,botocore==1.29.162,certifi==2023.5.7,cffi==1.15.1,charset-normalizer==3.1.0,cryptography==41.0.1,dnspython==2.3.0,idna==3.4,importlib-metadata==6.7.0,jmespath==1.0.1,mypy==1.2.0,mypy-extensions==1.0.0,pip==23.1.2,pyasn1==0.5.0,pyasn1-modules==0.3.0,pycparser==2.21,pymongo @ file:///home/runner/work/mongo-python-driver/mongo-python-driver/.tox/.tmp/package/1/pymongo-4.5.0.dev0.tar.gz#sha256=439c2c4c4ca66a6b9e802c399a50d5c15ad9550645378f785077657b61558202,pymongo-auth-aws==1.1.0,pymongocrypt==1.6.1,pyOpenSSL==23.2.0,python-dateutil==2.8.2,requests==2.31.0,s3transfer==0.6.1,service-identity==21.1.0,setuptools==67.8.0,six==1.16.0,tomli==2.0.1,typed-ast==1.5.4,typing_extensions==4.6.3,urllib3==1.26.16,wheel==0.40.0,zipp==3.15.0,zstandard==0.21.0
      typecheck-mypy: commands[0]> mypy --install-types --non-interactive bson gridfs tools pymongo
      Collecting types-pyOpenSSL
        Using cached types_pyOpenSSL-23.2.0.1-py3-none-any.whl (7.1 kB)
      Collecting types-requests
        Using cached types_requests-2.31.0.1-py3-none-any.whl (14 kB)
      Requirement already satisfied: cryptography>=35.0.0 in ./.tox/typecheck-mypy/lib/python3.7/site-packages (from types-pyOpenSSL) (41.0.1)
      Collecting types-urllib3 (from types-requests)
        Using cached types_urllib3-1.26.25.13-py3-none-any.whl (15 kB)
      Requirement already satisfied: cffi>=1.12 in ./.tox/typecheck-mypy/lib/python3.7/site-packages (from cryptography>=35.0.0->types-pyOpenSSL) (1.15.1)
      Requirement already satisfied: pycparser in ./.tox/typecheck-mypy/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.2.0.1 types-requests-2.31.0.1 types-urllib3-1.26.25.13
      pymongo/max_staleness_selectors.py: note: In function "_with_primary":
      pymongo/max_staleness_selectors.py:70: error: Unsupported operand types for -
      ("float" and "None")  [operator]
      Installing missing stub packages:
      /home/runner/work/mongo-python-driver/mongo-python-driver/.tox/typecheck-mypy/bin/python -m pip install types-pyOpenSSL types-requests
      
      
      Found 7 errors in 1 file (checked 85 source files)
                          (s.last_update_time - s.last_write_date)
                           ^
      pymongo/max_staleness_selectors.py:70: note: Right operand is of type "Optional[float]"
      pymongo/max_staleness_selectors.py:71: error: Item "None" of
      "Optional[ServerDescription]" has no attribute "last_update_time"  [union-attr]
                          - (primary.last_update_time - primary.last_write_date)
                             ^
      pymongo/max_staleness_selectors.py:71: error: Unsupported operand types for -
      ("float" and "None")  [operator]
                          - (primary.last_update_time - primary.last_write_date)
                             ^
      pymongo/max_staleness_selectors.py:71: note: Both left and right operands are unions
      pymongo/max_staleness_selectors.py:71: error: Item "None" of
      "Optional[ServerDescription]" has no attribute "last_write_date"  [union-attr]
                          - (primary.last_update_time - primary.last_write_date)
                                                        ^
      pymongo/max_staleness_selectors.py: note: In function "_no_primary":
      pymongo/max_staleness_selectors.py:96: error: Unsupported operand types for -
      ("float" and "None")  [operator]
                      staleness = smax.last_write_date - s.last_write_date + sel...
                                  ^
      pymongo/max_staleness_selectors.py:96: error: Unsupported operand types for -
      ("None" and "float")  [operator]
                      staleness = smax.last_write_date - s.last_write_date + sel...
                                  ^
      pymongo/max_staleness_selectors.py:96: error: Unsupported left operand type for
      - ("None")  [operator]
                      staleness = smax.last_write_date - s.last_write_date + sel...
                                  ^
      pymongo/max_staleness_selectors.py:96: note: Both left and right operands are unions
      typecheck-mypy: exit 1 (13.17 seconds) /home/runner/work/mongo-python-driver/mongo-python-driver> mypy --install-types --non-interactive bson gridfs tools pymongo pid=1884
      .pkg: _exit> python /opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/pyproject_api/_backend.py True setuptools.build_meta
        typecheck-mypy: FAIL code 1 (39.27=setup[26.10]+cmd[13.17] seconds)
        evaluation failed :( (39.53 seconds)
      Error: Process completed with exit code 1.
      

            Assignee:
            iris.ho@mongodb.com Iris Ho
            Reporter:
            iris.ho@mongodb.com Iris Ho
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: