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
38 changes: 38 additions & 0 deletions .github/workflows/basedpyright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: basedpyright

on:
pull_request:
push:
branches:
- main
- develop
- feature-*

jobs:
basedpyright:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
packages: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: 0.8.22
python-version: 3.11
enable-cache: true
cache-suffix: pre-commit
cache-dependency-glob: uv.lock
- name: Restore venv cache
uses: actions/cache@v4
with:
path: |
.venv
key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}
- name: Synchronize project dependencies
run: uv sync --group dev
- name: Run basedpyright
run: uv run basedpyright
9 changes: 3 additions & 6 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ jobs:
path: |
.venv
key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}
- name: Restore mypy cache
uses: actions/cache@v4
with:
path: .mypy_cache
key: mypy_cache|${{ hashFiles('pyproject.toml') }}
- name: Restore pre-commit cache
uses: actions/cache@v4
with:
Expand All @@ -45,4 +40,6 @@ jobs:
- name: Synchronize project dependencies
run: uv sync --group dev
- name: Run pre-commit checks
run: uv run pre-commit run --show-diff-on-failure --all-files --hook-stage manual
run: uv run pre-commit run --show-diff-on-failure --all-files
env:
SKIP: basedpyright
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -451,3 +451,5 @@ $RECYCLE.BIN/
# Profiling
*.prof.txt
*.speedscope.json

!pyrightconfig.json
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/git_toolbox_prj.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3,126 changes: 3,126 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions .idea/pdfrest-python.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/pyright.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/ruff.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 3 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,12 @@ repos:
rev: v0.24.3
hooks:
- id: toml-sort-fix
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.18.2"
hooks:
- id: mypy
stages: [pre-push, manual]
name: mypy
additional_dependencies:
# Need pydantic to load the pydantic.mypy plugin
- pydantic>=2.12.0
- repo: https://github.com/astral-sh/uv-pre-commit
# uv version.
rev: 0.8.24
hooks:
- id: uv-lock
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.406
- repo: https://github.com/DetachHead/basedpyright-pre-commit-mirror
rev: 1.34.0 # or whatever the latest version is at the time
hooks:
- id: pyright
- id: basedpyright
8 changes: 4 additions & 4 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
def tests(session: nox.Session) -> None:
# Define only custom flags
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument("--no-parallel", action="store_true")
parser.add_argument(
_ = parser.add_argument("--no-parallel", action="store_true")
_ = parser.add_argument(
"-n", "--workers", "--numprocesses"
) # e.g., -n 4 to set workers
custom, remaining = parser.parse_known_args(session.posargs)
Expand All @@ -27,7 +27,7 @@ def tests(session: nox.Session) -> None:
else:
pytest_args[:0] = ["-n", "8", "--maxschedchunk", "2"]

session.run_install(
_ = session.run_install(
"uv",
"sync",
"--no-default-groups",
Expand All @@ -36,7 +36,7 @@ def tests(session: nox.Session) -> None:
f"--python={session.virtualenv.location}",
env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location},
)
session.run(
_ = session.run(
"pytest",
"--cov=pdfrest",
"--cov-report=term-missing",
Expand Down
86 changes: 3 additions & 83 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,99 +22,17 @@ dev = [
"ruff>=0.6.9",
"pytest>=8.3.3",
"pytest-cov>=5.0.0",
"mypy>=1.18.2",
"pip-audit>=2.7.3",
"pyright>=1.1.406",
"pytest-md>=0.2.0",
"pytest-emoji>=0.2.0",
"pytest-dotenv>=0.5.2",
"pytest-asyncio>=1.2.0",
"pytest-rerunfailures>=16.0.1",
"pytest-xdist>=3.8.0",
"nox>=2025.5.1",
"basedpyright>=1.34.0",
]

[tool.mypy]
python_version = "3.10"
pretty = true
plugins = [
"pydantic.mypy",
]
# Discover modules that were installed in the virtualenv
python_executable = ".venv/bin/python"
fixed_format_cache = true
ignore_missing_imports = false
follow_imports = "silent"
# Balanced strictness (not “strict = true”); catches many bugs without being overbearing
no_implicit_optional = true
check_untyped_defs = true
warn_unused_ignores = true
warn_redundant_casts = true
warn_return_any = true
warn_no_return = true
strict_equality = true
# Defaults here stay a bit lenient; ratchet up over time if desired
disallow_untyped_defs = false
disallow_incomplete_defs = false
disallow_untyped_calls = false
disallow_any_generics = false
implicit_reexport = true
namespace_packages = true
show_error_codes = true
# Typical project structure
packages = ["pdfrest"] # if using setuptools; or rely on src/ layout
exclude = '(build|dist|\.venv|scripts|examples|docs)'

# Example: tighten src/, loosen tests/
[[tool.mypy.overrides]]
module = ["pdfrest.*"]
disallow_untyped_defs = true
disallow_incomplete_defs = true

[[tool.mypy.overrides]]
module = ["tests.*"]
disallow_untyped_defs = false
allow_redefinition = true

[tool.pyright]
venvPath = "."
venv = ".venv"
typeCheckingMode = "standard"
pythonVersion = "3.10"
reportMissingTypeStubs = true
# mypy catches this, so catch it in pyright too
reportOptionalMemberAccess = true
# Sensible signal without being punitive; tune severities as needed
reportUnusedImport = "error"
reportUnusedVariable = "error"
reportUnknownMemberType = "warning"
reportUnknownArgumentType = "warning"
reportUnknownVariableType = "warning"
reportPrivateUsage = "error"
# Keep false positives low in typical library code
useLibraryCodeForTypes = true
# Project layout
include = ["src", "tests"]
exclude = [
"**/.venv",
"build",
"dist",
"scripts",
"examples",
"docs",
]

[[tool.pyright.executionEnvironments]]
root = "src"

[[tool.pyright.executionEnvironments]]
root = "tests"
typeCheckingMode = "basic"
reportUnknownMemberType = "none"
reportUnknownArgumentType = "none"
reportUnknownVariableType = "none"
reportPrivateUsage = "none"

[tool.pytest.ini_options]
minversion = "7.4"
testpaths = ["tests"]
Expand Down Expand Up @@ -185,6 +103,8 @@ trailing_comma_inline_array = true

[tool.uv]
keyring-provider = "subprocess"
no-build = true
no-binary-package = ["pdfrest"]

[[tool.uv.index]]
name = "cit-pypi"
Expand Down
37 changes: 37 additions & 0 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"include": ["src", "tests", "noxfile.py"],
"exclude": [
"**/.venv",
"build",
"dist",
"scripts",
"examples",
"docs",
"**/node_modules",
"**/__pycache__"
],
"pythonVersion": "3.10",
"reportImplicitStringConcatenation": "none",
"reportAny": "none",
"reportExplicitAny": "none",
"reportUnannotatedClassAttribute": "none",
"executionEnvironments": [
{
"root": "noxfile.py"
},
{
"root": "src"
},
{
"root": "tests",
"reportUnknownLambdaType": "none",
"reportUnknownMemberType": "none",
"reportArgumentType": "none",
"reportUnknownArgumentType": "none",
"reportUnknownVariableType": "none",
"reportPrivateUsage": "none",
"reportUnusedCallResult": "none",
"reportPrivateLocalImportUsage": "none"
}
]
}
Loading