Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion template/pyproject.toml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ description = "Run {{ type_checker }}"
commands = [
[
"{{ type_checker }}",
"src",
{% if type_checker=="pyright" %}"--pythonpath",
".venv/bin/python",
{% endif %}"src",
"tests",
{ replace = "posargs", default = [
], extend = true },
Expand Down
23 changes: 23 additions & 0 deletions tests/test_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ def test_example_repo_updates(tmp_path: Path):
output = run(
# Git directory expected to be different
"diff -ur --exclude=.git "
# uv lock expected to be different
"--exclude=uv.lock "
# The commit hash is different for some reason
"--ignore-matching-lines='^_commit: ' "
# If we tag an existing commit that has been pushed to main, then the copier
Expand Down Expand Up @@ -256,6 +258,27 @@ def test_pyright_works_in_standard_typing_mode(tmp_path: Path):
run(f".venv/bin/pyright {tmp_path}")


def test_pyright_works_with_external_deps(tmp_path: Path):
copy_project(tmp_path)
# Add an external dependency
pyproject_toml = tmp_path / "pyproject.toml"
text = pyproject_toml.read_text().replace(
"dependencies = []", 'dependencies = ["numpy"]'
)
pyproject_toml.write_text(text)
# And some code that uses it
src_file = tmp_path / "src" / "python_copier_template_example" / "example.py"
src_file.write_text("""
import numpy as np

def is_big(arr: np.ndarray) -> bool:
return arr.size > 0
""")
# Ensure pyright is still happy
run = make_venv(tmp_path)
run(".venv/bin/tox -e type-checking")


def test_ignores_mypy_strict_mode(tmp_path: Path):
copy_project(tmp_path, type_checker="mypy", strict_typing=True)
pyproject_toml = tmp_path / "pyproject.toml"
Expand Down