Skip to content
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

types: Types checks reporting issues after updating watchdog to 3.0.0. Same issue with 4.0.0 #1035

Open
swetayadav1 opened this issue Feb 29, 2024 · 5 comments

Comments

@swetayadav1
Copy link

Issue:

Getting type issues after updating watchdog to 3.0.0.

Python version: 3.9.5
watchdog: 3.0.0

types installed: apipkg==1.5,appdirs==1.4.4,attrs==23.1.0,Authlib==1.3.0,black==23.12.1,boto3==1.34.17,botocore==1.34.17,certifi==2023.7.22,cffi==1.15.1,cfgv==3.4.0,chardet==4.0.0,charset-normalizer==2.1.1,click==8.0.1,codespell==2.2.6,coverage==7.3.1,cryptography==41.0.7,distlib==0.3.8,docutils==0.20.1,dukpy==0.2.3,exceptiongroup==1.2.0,execnet==2.0.2,Faker==22.0.0,filelock==3.12.4,flake8==6.1.0,future==0.18.3,identify==2.5.33,idna==3.6,importlib-metadata==7.0.1,iniconfig==2.0.0,jmespath==1.0.1,junitparser==3.1.1,jwt==1.3.1,mccabe==0.7.0,more-itertools==10.2.0,mypy==1.5.1,mypy-extensions==1.0.0,nodeenv==1.8.0,nuxeo==6.1.1,packaging==23.1,pathspec==0.12.1,pep517==0.10.0,pip-tools==6.5.1,platformdirs==3.10.0,pluggy==1.3.0,pre-commit==2.16.0,psutil==5.8.0,py==1.10.0,pycodestyle==2.11.1,pycparser==2.21,pyfakefs==5.3.4,pyflakes==3.1.0,pyobjc-core==10.1,pyobjc-framework-Cocoa==10.1,pyobjc-framework-CoreServices==10.1,pyobjc-framework-FSEvents==10.1,pyobjc-framework-ScriptingBridge==10.1,pyobjc-framework-SystemConfiguration==10.1,PyPAC==0.15.0,pyparsing==2.4.7,PyQt5==5.15.2,PyQt5-sip==12.8.1,PyQt5-stubs==5.15.6.0,pytest==7.4.4,pytest-cov==4.1.0,pytest-forked==1.6.0,pytest-timeout==2.2.0,pytest-xdist==3.3.1,python-dateutil==2.8.2,PyYAML==6.0.1,regex==2023.12.25,requests==2.31.0,responses==0.24.1,s3transfer==0.10.0,sentry-sdk==1.28.1,six==1.16.0,text-unidecode==1.3,tld==0.12.6,toml==0.10.2,tomli==2.0.1,tox==3.24.5,typed-ast==1.5.5,types-certifi==2021.10.8.3,types-python-dateutil==2.8.19.20240106,types-PyYAML==6.0.12.12,types-requests==2.26.1,typing_extensions==4.9.0,urllib3==1.26.12,virtualenv==20.4.7,vulture==2.10,watchdog==3.0.0,wcwidth==0.2.6,xattr==0.9.7,zipp==3.5.0
types run-test-pre: PYTHONHASHSEED='2899401531'
types run-test: commands[0] | pip-sync tools/deps/requirements-pip.txt tools/deps/requirements-tests.txt
Collecting watchdog==4.0.0
  Using cached watchdog-4.0.0-cp39-cp39-macosx_10_9_x86_64.whl (92 kB)
Installing collected packages: watchdog
  Attempting uninstall: watchdog
    Found existing installation: watchdog 3.0.0
    Uninstalling watchdog-3.0.0:
      Successfully uninstalled watchdog-3.0.0
Successfully installed watchdog-4.0.0
WARNING: You are using pip version 22.0.4; however, version 24.0 is available.
You should consider upgrading via the '/Users/sweta.yadav/projects/nuxeo-drive/.tox/base/bin/python -m pip install --upgrade pip' command.
types run-test: commands[1] | python -m mypy --platform win32 nxdrive
nxdrive/engine/watcher/local_watcher.py:93: error: Variable "watchdog.observers.Observer" is not valid as a type  [valid-type]
nxdrive/engine/watcher/local_watcher.py:93: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
nxdrive/engine/watcher/local_watcher.py:626: error: Call to untyped function "schedule" in typed context  [no-untyped-call]
nxdrive/engine/watcher/local_watcher.py:629: error: Call to untyped function "start" in typed context  [no-untyped-call]
nxdrive/engine/watcher/local_watcher.py:1302: error: Call to untyped function "__init__" in typed context  [no-untyped-call]
nxdrive/direct_edit.py:99: error: Variable "watchdog.observers.Observer" is not valid as a type  [valid-type]
nxdrive/direct_edit.py:99: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
nxdrive/direct_edit.py:1045: error: Call to untyped function "schedule" in typed context  [no-untyped-call]
nxdrive/direct_edit.py:1046: error: Call to untyped function "start" in typed context  [no-untyped-call]
Found 7 errors in 2 files (checked 104 source files)

Solution tried but didn't work:

  • Updated watchdog to 4.0.0
  • Workaround suggested in issuecomment-1559536196 by replacing "watchdog.observers.Observer" with "watchdog.obersvers.api.BaseObserver"
@BoboTiG
Copy link
Collaborator

BoboTiG commented Feb 29, 2024

(Nice to see you upstream issues :)

Could you give a try with mypy 1.8.0?

@swetayadav1
Copy link
Author

swetayadav1 commented Mar 1, 2024

Thank you for quick response @BoboTiG

Tried with mypy 1.8.0 and watchdog 4.0.0. Have same issue

types installed: apipkg==1.5,appdirs==1.4.4,attrs==23.1.0,Authlib==1.3.0,black==23.12.1,boto3==1.34.17,botocore==1.34.17,certifi==2023.7.22,cffi==1.15.1,cfgv==3.4.0,chardet==4.0.0,charset-normalizer==2.1.1,click==8.0.1,codespell==2.2.6,coverage==7.3.1,cryptography==41.0.7,distlib==0.3.8,docutils==0.20.1,dukpy==0.2.3,exceptiongroup==1.2.0,execnet==2.0.2,Faker==22.0.0,filelock==3.12.4,flake8==6.1.0,future==0.18.3,identify==2.5.33,idna==3.6,importlib-metadata==7.0.1,iniconfig==2.0.0,jmespath==1.0.1,junitparser==3.1.1,jwt==1.3.1,mccabe==0.7.0,more-itertools==10.2.0,mypy==1.5.1,mypy-extensions==1.0.0,nodeenv==1.8.0,nuxeo==6.1.1,packaging==23.1,pathspec==0.12.1,pep517==0.10.0,pip-tools==6.5.1,platformdirs==3.10.0,pluggy==1.3.0,pre-commit==2.16.0,psutil==5.8.0,py==1.10.0,pycodestyle==2.11.1,pycparser==2.21,pyfakefs==5.3.4,pyflakes==3.1.0,pyobjc-core==10.1,pyobjc-framework-Cocoa==10.1,pyobjc-framework-CoreServices==10.1,pyobjc-framework-FSEvents==10.1,pyobjc-framework-ScriptingBridge==10.1,pyobjc-framework-SystemConfiguration==10.1,PyPAC==0.15.0,pyparsing==2.4.7,PyQt5==5.15.2,PyQt5-sip==12.8.1,PyQt5-stubs==5.15.6.0,pytest==7.4.4,pytest-cov==4.1.0,pytest-forked==1.6.0,pytest-timeout==2.2.0,pytest-xdist==3.3.1,python-dateutil==2.8.2,PyYAML==6.0.1,regex==2023.12.25,requests==2.31.0,responses==0.24.1,s3transfer==0.10.0,sentry-sdk==1.28.1,six==1.16.0,text-unidecode==1.3,tld==0.12.6,toml==0.10.2,tomli==2.0.1,tox==3.24.5,typed-ast==1.5.5,types-certifi==2021.10.8.3,types-python-dateutil==2.8.19.20240106,types-PyYAML==6.0.12.12,types-requests==2.26.1,typing_extensions==4.9.0,urllib3==1.26.12,virtualenv==20.4.7,vulture==2.10,watchdog==4.0.0,wcwidth==0.2.6,xattr==0.9.7,zipp==3.5.0
types run-test-pre: PYTHONHASHSEED='1164668819'
types run-test: commands[0] | pip-sync tools/deps/requirements-pip.txt tools/deps/requirements-tests.txt
Collecting mypy==1.8.0
  Downloading mypy-1.8.0-cp39-cp39-macosx_10_9_x86_64.whl (10.9 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.9/10.9 MB 5.9 MB/s eta 0:00:00
Requirement already satisfied: mypy-extensions>=1.0.0 in ./.tox/base/lib/python3.9/site-packages (from mypy==1.8.0->-r /var/folders/7n/dlk2vs4n1fgc2hkrm7hhx5ymynpf8b/T/tmpt9elfp6k (line 1)) (1.0.0)
Requirement already satisfied: typing-extensions>=4.1.0 in ./.tox/base/lib/python3.9/site-packages (from mypy==1.8.0->-r /var/folders/7n/dlk2vs4n1fgc2hkrm7hhx5ymynpf8b/T/tmpt9elfp6k (line 1)) (4.9.0)
Requirement already satisfied: tomli>=1.1.0 in ./.tox/base/lib/python3.9/site-packages (from mypy==1.8.0->-r /var/folders/7n/dlk2vs4n1fgc2hkrm7hhx5ymynpf8b/T/tmpt9elfp6k (line 1)) (2.0.1)
Installing collected packages: mypy
  Attempting uninstall: mypy
    Found existing installation: mypy 1.5.1
    Uninstalling mypy-1.5.1:
      Successfully uninstalled mypy-1.5.1
Successfully installed mypy-1.8.0
WARNING: You are using pip version 22.0.4; however, version 24.0 is available.
You should consider upgrading via the '/Users/sweta.yadav/projects/nuxeo-drive/.tox/base/bin/python -m pip install --upgrade pip' command.
types run-test: commands[1] | python -m mypy --platform win32 nxdrive
nxdrive/engine/watcher/local_watcher.py:93: error: Variable "watchdog.observers.Observer" is not valid as a type  [valid-type]
nxdrive/engine/watcher/local_watcher.py:93: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
nxdrive/engine/watcher/local_watcher.py:626: error: Call to untyped function "schedule" in typed context  [no-untyped-call]
nxdrive/engine/watcher/local_watcher.py:629: error: Call to untyped function "start" in typed context  [no-untyped-call]
nxdrive/engine/watcher/local_watcher.py:1302: error: Call to untyped function "__init__" in typed context  [no-untyped-call]
nxdrive/direct_edit.py:99: error: Variable "watchdog.observers.Observer" is not valid as a type  [valid-type]
nxdrive/direct_edit.py:99: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
nxdrive/direct_edit.py:1045: error: Call to untyped function "schedule" in typed context  [no-untyped-call]
nxdrive/direct_edit.py:1046: error: Call to untyped function "start" in typed context  [no-untyped-call]
Found 7 errors in 2 files (checked 104 source files)

@BoboTiG
Copy link
Collaborator

BoboTiG commented Mar 1, 2024

Can you share the code at nxdrive/engine/watcher/local_watcher.py:93 and nxdrive/direct_edit.py:1045?

I'll try to reproduce and see what can be done.

@swetayadav1
Copy link
Author

We have implemented watchdog in same way as mentioned in official documentation watchdog
Here is the link for Nuxeo Drive Types failure Types Error

@swetayadav1
Copy link
Author

Hi @BoboTiG Did you get a chance to look into it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants