aboutcode-org / aboutcode-org/scancode-toolkit
Provide type hints for PEP 561 compliance
- Vorherrschende Sprache
- Python
- Sterne
- 2.6k
- Forks
- 791
- Ø Merge
- 1 T. 12 Std.
- Gemergte PRs (30 T.)
- 5
Beschreibung
## Short Description
To use the ScanCode toolkit as a library, it would be great if type hints for corresponding checkers like *mypy* would be provided.
## Possible Labels
- new feature
- enhancement
## Select Category
- [X] Enhancement
- [ ] Add License/Copyright
- [ ] Scan Feature
- [ ] Packaging
- [ ] Documentation
- [ ] Expand Support
- [ ] Other
## **Describe the Update**
ScanCode toolkit and the corresponding dependencies like *commoncode* should receive type hints and target PEP 561 with this.
## **How This Feature will help you/your organization**
As already mentioned in #3431, I am primarily using ScanCode toolkit as a library for license scanning. Properly typing my code requires suitable typing information for all dependencies as well and avoid possible type issues.
At the moment, running corresponding tools like *mypy* requires me to ignore warnings about possibly untyped code:
```bash
stefan@localhost ~/projects/license_tools $ mypy license_tools
license_tools/scancode_tools.py:24: error: Skipping analyzing "scancode_config": module is installed, but missing library stubs or py.typed marker [import]
license_tools/scancode_tools.py:24: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
license_tools/scancode_tools.py:25: error: Skipping analyzing "commoncode": module is installed, but missing library stubs or py.typed marker [import]
license_tools/scancode_tools.py:27: error: Skipping analyzing "scancode": module is installed, but missing library stubs or py.typed marker [import]
```
## **Possible Solution/Implementation Details**
The stdlib *typing* module provides support for typing: https://docs.python.org/3/library/typing.html Starting at Python 3.8, some aspects might be simplified due to support for the new `from __future__ import annotations` functionality.
*mypy* provides the *stubgen* tool for generating `*.pyi` stubs with harmless dummy data which pass all type checks: https://mypy.readthedocs.io/en/stable/stubgen.html Nevertheless, I would probably recommend to work on the actual code directly as the `*.pyi` files are just some sort of workaround.
Once fully typed, a `py.typed` file should be shipped with the corresponding packages.
## **Can you help with this Feature**
The ScanCode/nexB ecosystem is quite large, thus probably requiring work across multiple repositories and prioritization. I would be up to support with this process.
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.