Skip to content

Commit 6372ae3

Browse files
Make strict mode the default
Set the default state of the template to pyright with strict mode, the user must conciously disable it. This is in line with the recommended approach in the docs of using strict mode fro new projects if practical.
1 parent 972c1ce commit 6372ae3

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

copier.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ strict_typing:
126126
type: bool
127127
when: >-
128128
{{ type_checker == 'pyright' }}
129-
default: false
129+
default: true
130130
help: |
131131
Would you like to run pyright in strict mode?
132132
The recommended approach is to start with strict mode and disable it if it

example-answers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ github_org: DiamondLightSource
1212
package_name: python_copier_template_example
1313
repo_name: python-copier-template-example
1414
type_checker: pyright
15-
strict_typing: false
15+
strict_typing: true
1616
pypi: true

tests/test_example.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def test_template_defaults(tmp_path: Path):
5252
assert container_doc.exists()
5353
catalog_info = tmp_path / "catalog-info.yaml"
5454
assert catalog_info.exists()
55-
assert 'typeCheckingMode = "standard"' in pyproject_toml.read_text()
55+
assert 'typeCheckingMode = "strict"' in pyproject_toml.read_text()
5656
run("./venv/bin/tox -p")
5757
if not run_pipe("git tag --points-at HEAD"):
5858
# Only run linkcheck if not on a tag, as the CI might not have pushed
@@ -70,8 +70,16 @@ def test_template_with_extra_code_and_api_docs(tmp_path: Path):
7070
init = tmp_path / "src" / "python_copier_template_example" / "__init__.py"
7171
init.write_text(
7272
init.read_text().replace(
73-
"__all__ = [",
73+
"""
74+
from ._version import __version__
75+
76+
__all__ = [""",
7477
'''
78+
from python_copier_template_example import extra_pkg
79+
80+
from ._version import __version__
81+
82+
7583
class TopCls:
7684
"""A top level class."""
7785
@@ -215,12 +223,12 @@ def __init__(self):
215223
run("ruff check")
216224

217225

218-
def test_pyright_works_in_strict_typing_mode(tmp_path: Path):
219-
copy_project(tmp_path, type_checker="pyright", strict_typing=True)
226+
def test_pyright_works_in_standard_typing_mode(tmp_path: Path):
227+
copy_project(tmp_path, type_checker="pyright", strict_typing=False)
220228
pyproject_toml = tmp_path / "pyproject.toml"
221229

222-
# Check strict mode is configured
223-
assert 'typeCheckingMode = "strict"' in pyproject_toml.read_text()
230+
# Check standard mode is configured
231+
assert 'typeCheckingMode = "standard"' in pyproject_toml.read_text()
224232

225233
# Ensure pyright is still happy
226234
run = make_venv(tmp_path)

0 commit comments

Comments
 (0)