Skip to content

Commit da75861

Browse files
pyproject: pyright and mypy settings that work together
1 parent 70fd80b commit da75861

1 file changed

Lines changed: 66 additions & 8 deletions

File tree

pyproject.toml

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,84 @@ dev = [
3636

3737
[tool.mypy]
3838
python_version = "3.10"
39-
warn_return_any = true
4039
pretty = true
41-
exclude = [
42-
'^\\.venv', # TOML literal string (single-quotes, no escaping necessary)
43-
'^build', # Skip build artifacts
44-
'^dist', # Skip distribution artifacts
45-
]
46-
files = "."
4740
plugins = [
4841
"pydantic.mypy",
4942
]
5043
# Discover modules that were installed in the virtualenv
5144
python_executable = ".venv/bin/python"
5245
fixed_format_cache = true
46+
ignore_missing_imports = false
47+
follow_imports = "silent"
48+
# Balanced strictness (not “strict = true”); catches many bugs without being overbearing
49+
no_implicit_optional = true
50+
check_untyped_defs = true
51+
warn_unused_ignores = true
52+
warn_redundant_casts = true
53+
warn_return_any = true
54+
warn_no_return = true
55+
strict_equality = true
56+
# Defaults here stay a bit lenient; ratchet up over time if desired
57+
disallow_untyped_defs = false
58+
disallow_incomplete_defs = false
59+
disallow_untyped_calls = false
60+
disallow_any_generics = false
61+
implicit_reexport = true
62+
namespace_packages = true
63+
show_error_codes = true
64+
# Typical project structure
65+
packages = ["pdfrest"] # if using setuptools; or rely on src/ layout
66+
exclude = '(build|dist|\.venv|scripts|examples|docs)'
67+
68+
# Example: tighten src/, loosen tests/
69+
[[tool.mypy.overrides]]
70+
module = ["pdfrest.*"]
71+
disallow_untyped_defs = true
72+
disallow_incomplete_defs = true
73+
74+
[[tool.mypy.overrides]]
75+
module = ["tests.*"]
76+
disallow_untyped_defs = false
77+
allow_redefinition = true
5378

5479
[tool.pyright]
5580
venvPath = "."
5681
venv = ".venv"
82+
typeCheckingMode = "standard"
5783
pythonVersion = "3.10"
58-
typeCheckingMode = "strict"
84+
reportMissingTypeStubs = true
85+
# mypy catches this, so catch it in pyright too
86+
reportOptionalMemberAccess = true
87+
# Sensible signal without being punitive; tune severities as needed
88+
reportUnusedImport = "error"
89+
reportUnusedVariable = "error"
90+
reportUnknownMemberType = "warning"
91+
reportUnknownArgumentType = "warning"
92+
reportUnknownVariableType = "warning"
93+
reportPrivateUsage = "error"
94+
# Keep false positives low in typical library code
95+
useLibraryCodeForTypes = true
96+
# Project layout
97+
include = ["src", "tests"]
98+
exclude = [
99+
"**/.venv",
100+
"build",
101+
"dist",
102+
"scripts",
103+
"examples",
104+
"docs",
105+
]
106+
107+
[[tool.pyright.executionEnvironments]]
108+
root = "src"
109+
110+
[[tool.pyright.executionEnvironments]]
111+
root = "tests"
112+
typeCheckingMode = "basic"
113+
reportUnknownMemberType = "none"
114+
reportUnknownArgumentType = "none"
115+
reportUnknownVariableType = "none"
116+
reportPrivateUsage = "none"
59117

60118
[tool.pytest.ini_options]
61119
minversion = "7.4"

0 commit comments

Comments
 (0)