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

Add type checking for Python templates #317

Open
vdusek opened this issue Feb 18, 2025 · 1 comment
Open

Add type checking for Python templates #317

vdusek opened this issue Feb 18, 2025 · 1 comment
Assignees
Labels
infrastructure Issues related to infrastructure or CI/CD pipeline. t-tooling Issues with this label are in the ownership of the tooling team.

Comments

@vdusek
Copy link
Contributor

vdusek commented Feb 18, 2025

Problem: mypy reports duplicate module errors because all Python templates include a src package:

$ make type-check
uv run mypy
templates/python-crawlee-beautifulsoup/src/__init__.py: error: Duplicate module named "src" (also at "templates/python-beautifulsoup/src/__init__.py")
templates/python-crawlee-beautifulsoup/src/__init__.py: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#mapping-file-paths-to-modules for more info
templates/python-crawlee-beautifulsoup/src/__init__.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)
make: *** [Makefile:16: type-check] Error 2

We will have to rename them.

@vdusek vdusek added infrastructure Issues related to infrastructure or CI/CD pipeline. t-tooling Issues with this label are in the ownership of the tooling team. labels Feb 18, 2025
vdusek added a commit that referenced this issue Feb 18, 2025
Add static analysis (Ruff, Mypy) for Python templates.

Edit: Mypy will require further updates due to our usage of `src/`:

```
$ make type-check 
poetry run mypy
templates/python-crawlee-beautifulsoup/src/__init__.py: error: Duplicate module named "src" (also at "templates/python-beautifulsoup/src/__init__.py")
templates/python-crawlee-beautifulsoup/src/__init__.py: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#mapping-file-paths-to-modules for more info
templates/python-crawlee-beautifulsoup/src/__init__.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)
make: *** [Makefile:16: type-check] Error 2
```

This will be addressed later in
[#317](#317 (comment)).
@B4nan
Copy link
Member

B4nan commented Feb 24, 2025

lets run the checks per each template instead of ones for the whole templates repository

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure Issues related to infrastructure or CI/CD pipeline. t-tooling Issues with this label are in the ownership of the tooling team.
Projects
None yet
Development

No branches or pull requests

2 participants