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

error: Can't determine which types to install with no files to check (and no cache from previous mypy run) #413

Open
BaseMax opened this issue Dec 25, 2024 · 7 comments
Assignees

Comments

@BaseMax
Copy link
Member

BaseMax commented Dec 25, 2024

$ pre-commit run --all-files
....
....
config\module\utils.py:3: error: Library stubs not installed for "yaml"  [import-untyped]
config\layout\attribute\style\value.convert.py:1: error: Library stubs not installed for "yaml"  [import-untyped]
config\admin\app.py:5: error: Library stubs not installed for "yaml"  [import-untyped]
config\admin\app.py:5: note: Hint: "python3 -m pip install types-PyYAML"
config\admin\app.py:5: note: (or run "mypy --install-types" to install all missing stub packages)
config\admin\app.py:5: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
config\sync.py:6: error: Library stubs not installed for "yaml"  [import-untyped]
Found 4 errors in 4 files (checked 16 source files)


C:\Files\Projects\Salam>cd config

C:\Files\Projects\Salam\config>
C:\Files\Projects\Salam\config>mypy --install-types
error: Can't determine which types to install with no files to check (and no cache from previous mypy run)

C:\Files\Projects\Salam\config>mypy run
mypy: can't read file 'run': No such file or directory
@BaseMax
Copy link
Member Author

BaseMax commented Dec 25, 2024

cc @BDadmehr0

@BDadmehr0
Copy link
Member

I run this command, "mypy --install-types," to solve the "import-untyped" issue, but the problem still persists.
Now you've encountered another error, and I wanted to let you know that I had already tried this command, but it didn't work. @BaseMax

@BDadmehr0
Copy link
Member

mypy: can't read file 'run': No such file or directory

mypy <file_or_directory>

@BDadmehr0
Copy link
Member

C:\Files\Projects\Salam\config>mypy --install-types
error: Can't determine which types to install with no files to check (and no cache from previous mypy run)

python/mypy#10600

@BaseMax
Copy link
Member Author

BaseMax commented Dec 25, 2024

C:\Files\Projects\Salam>mypy config
config\layout\attribute\type.validate.py: error: Duplicate module named "type.validate" (also at "config\layout\attribute\style\type.validate.py")
config\layout\attribute\type.validate.py: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#mapping-file-paths-to-modules for more info
config\layout\attribute\type.validate.py: note: Common resolutions include: a) using `--exclude` to avoid checking one of them, b) adding `__init__.py` somewhere, c) using `--explicit-package-bases` or adjusting MYPYPATH
Found 1 error in 1 file (errors prevented further checking)

and

C:\Files\Projects\Salam\config\admin>mypy .
app.py:4: error: Cannot find implementation or library stub for module named "werkzeug"  [import-not-found]
app.py:4: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
app.py:6: error: Cannot find implementation or library stub for module named "flask"  [import-not-found]
Found 2 errors in 1 file (checked 1 source file)

@BDadmehr0
Copy link
Member

BDadmehr0 commented Dec 25, 2024

C:\Files\Projects\Salam>mypy config
config\layout\attribute\type.validate.py: error: Duplicate module named "type.validate" (also at "config\layout\attribute\style\type.validate.py")
config\layout\attribute\type.validate.py: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#mapping-file-paths-to-modules for more info
config\layout\attribute\type.validate.py: note: Common resolutions include: a) using `--exclude` to avoid checking one of them, b) adding `__init__.py` somewhere, c) using `--explicit-package-bases` or adjusting MYPYPATH
Found 1 error in 1 file (errors prevented further checking)

and

C:\Files\Projects\Salam\config\admin>mypy .
app.py:4: error: Cannot find implementation or library stub for module named "werkzeug"  [import-not-found]
app.py:4: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
app.py:6: error: Cannot find implementation or library stub for module named "flask"  [import-not-found]
Found 2 errors in 1 file (checked 1 source file)

@BaseMax use this these arguments: mypy . --ignore-missing-imports --explicit-package-bases in /config dirctory

  1. --ignore-missing-imports: This tells mypy to ignore modules it cannot locate, preventing unnecessary errors during type checking. It is useful for projects with missing or untyped dependencies.

  2. --explicit-package-bases: This forces mypy to use precise directory paths for package detection, which is helpful in projects with complex or non-standard structures.

This helps you catch more important errors and resolve them.

@BaseMax
Copy link
Member Author

BaseMax commented Dec 25, 2024

Thanks, output is:

C:\Files\Projects\Salam\config>mypy . --ignore-missing-imports --explicit-package-bases
Success: no issues found in 14 source files

I guess we still have some errors/warnings about mypy in pre-commit, please check.

Best
M.

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