Closed callumforrester closed 3 months ago
The current set of type errors in strict mode:
$ tox -e type-checking
type-checking installed: accessible-pygments==0.0.5,alabaster==1.0.0,annotated-types==0.7.0,anyio==4.4.0,Babel==2.15.0,beautifulsoup4==4.12.3,certifi==2024.7.4,cfgv==3.4.0,charset-normalizer==3.3.2,click==8.1.7,colorama==0.4.6,copier==9.3.1,coverage==7.6.1,distlib==0.3.8,# Editable Git install with no remote (dls-python-copier-template-example==0.1.dev0+d20240808),-e /home/vid18871/projects/dev-tools/python-copier-template-example,docutils==0.21.2,dunamai==1.22.0,exceptiongroup==1.2.2,filelock==3.15.4,funcy==2.0,h11==0.14.0,identify==2.6.0,idna==3.7,imagesize==1.4.1,iniconfig==2.0.0,Jinja2==3.1.4,jinja2-ansible-filters==1.3.2,markdown-it-py==3.0.0,MarkupSafe==2.1.5,mdit-py-plugins==0.4.1,mdurl==0.1.2,myst-parser==4.0.0,nodeenv==1.9.1,packaging==24.1,pathlib2==2.3.7.post1,pathspec==0.12.1,pipdeptree==2.23.1,platformdirs==4.2.2,pluggy==1.5.0,plumbum==1.8.3,pre-commit==3.8.0,prompt-toolkit==3.0.36,py==1.11.0,pydantic==2.8.2,pydantic_core==2.20.1,pydata-sphinx-theme==0.15.4,Pygments==2.18.0,pyright==1.1.375,pytest==8.3.2,pytest-cov==5.0.0,PyYAML==6.0.2,questionary==2.0.1,requests==2.32.3,ruff==0.5.6,six==1.16.0,sniffio==1.3.1,snowballstemmer==2.2.0,soupsieve==2.5,Sphinx==8.0.2,sphinx-autobuild==2024.4.16,sphinx-copybutton==0.5.2,sphinx_design==0.6.1,sphinxcontrib-applehelp==2.0.0,sphinxcontrib-devhelp==2.0.0,sphinxcontrib-htmlhelp==2.1.0,sphinxcontrib-jsmath==1.0.1,sphinxcontrib-qthelp==2.0.0,sphinxcontrib-serializinghtml==2.0.0,starlette==0.38.2,tomli==2.0.1,tox==3.28.0,tox-direct==0.4,types-mock==5.1.0.20240425,typing_extensions==4.12.2,urllib3==2.2.2,uvicorn==0.30.5,virtualenv==20.26.3,watchfiles==0.23.0,wcwidth==0.2.13,websockets==12.0
type-checking run-test-pre: PYTHONHASHSEED='4164938286'
type-checking run-test: commands[0] | pyright src tests
/home/vid18871/projects/dev-tools/python-copier-template-example/src/python_copier_template_example/__main__.py
/home/vid18871/projects/dev-tools/python-copier-template-example/src/python_copier_template_example/__main__.py:8:10 - error: Type of parameter "args" is partially unknown
Parameter type is "Unknown | None" (reportUnknownParameterType)
/home/vid18871/projects/dev-tools/python-copier-template-example/src/python_copier_template_example/__main__.py:8:10 - error: Type annotation is missing for parameter "args" (reportMissingParameterType)
/home/vid18871/projects/dev-tools/python-copier-template-example/src/python_copier_template_example/__main__.py:11:30 - error: Argument type is partially unknown
Argument corresponds to parameter "args" in function "parse_args"
Argument type is "Unknown | None" (reportUnknownArgumentType)
/home/vid18871/projects/dev-tools/python-copier-template-example/tests/conftest.py
/home/vid18871/projects/dev-tools/python-copier-template-example/tests/conftest.py:10:35 - error: Type of parameter "call" is unknown (reportUnknownParameterType)
/home/vid18871/projects/dev-tools/python-copier-template-example/tests/conftest.py:10:35 - error: Type annotation is missing for parameter "call" (reportMissingParameterType)
/home/vid18871/projects/dev-tools/python-copier-template-example/tests/conftest.py:11:15 - error: Type of "excinfo" is unknown (reportUnknownMemberType)
/home/vid18871/projects/dev-tools/python-copier-template-example/tests/conftest.py:11:15 - error: Type of "value" is unknown (reportUnknownMemberType)
/home/vid18871/projects/dev-tools/python-copier-template-example/tests/conftest.py:14:30 - error: Type of parameter "excinfo" is unknown (reportUnknownParameterType)
/home/vid18871/projects/dev-tools/python-copier-template-example/tests/conftest.py:14:30 - error: Type annotation is missing for parameter "excinfo" (reportMissingParameterType)
/home/vid18871/projects/dev-tools/python-copier-template-example/tests/conftest.py:15:15 - error: Type of "value" is unknown (reportUnknownMemberType)
10 errors, 0 warnings, 0 informations
ERROR: InvocationError for command /home/vid18871/projects/dev-tools/python-copier-template-example/venv/bin/pyright src tests (exited with code 1)
______________________________________________________________________________ summary ______________________________________________________________________________
ERROR: type-checking: commands failed
As a developer I would like to enable pyright's strict mode (see the config docs) so that I can deploy core projects with a higher degree of certainty and catch more errors before runtime.
I do not believe the config should be included in the template, it's one line:
I do believe we should have a test that proves the example template won't generate any errors if we switch it to strict mode, to lower the barrier to entry.
Acceptance Criteria
strict = ["src", "tests"]
to the pyright section inpyproject.toml
tox -e type-checking
without getting any new type errors