Skip to content

Commit 69c7c3b

Browse files
authored
Merge pull request #32 from waketzheng/main
chore: upgrade deps, improve type hints and add make file for development
2 parents 3ab7252 + 97e57a8 commit 69c7c3b

File tree

18 files changed

+234
-90
lines changed

18 files changed

+234
-90
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
*.py[cod]
33
__pycache__/
44
venv/
5+
.venv/
56
.tox/
67
.vscode/
78
/build/

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ exclude: >
1414
1515
repos:
1616
- repo: https://github.com/astral-sh/ruff-pre-commit
17-
rev: 'v0.0.276'
17+
rev: 'v0.9.7'
1818
hooks:
1919
- id: ruff
2020
args: [--fix, --exit-non-zero-on-fix, --show-fixes]
2121

2222
- repo: https://github.com/ambv/black
23-
rev: 23.3.0
23+
rev: 24.8.0
2424
hooks:
2525
- id: black
2626

Makefile

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
checkfiles = src/ tests/
2+
3+
help:
4+
@echo "FindPython development makefile"
5+
@echo
6+
@echo "Usage: make <target>"
7+
@echo "Targets:"
8+
@echo " up Updates dev/test dependencies"
9+
@echo " deps Ensure dev/test dependencies are installed"
10+
@echo " check Checks that build is sane"
11+
@echo " test Runs all tests"
12+
@echo " style Auto-formats the code"
13+
@echo " lint Auto-formats the code and check type hints"
14+
15+
up:
16+
pdm update --verbose
17+
18+
deps:
19+
ifeq ($(wildcard .venv),)
20+
pdm install --verbose
21+
else
22+
pdm install
23+
endif
24+
25+
_check:
26+
pdm run ruff format --check $(checkfiles)
27+
pdm run ruff check $(checkfiles)
28+
pdm run mypy $(checkfiles)
29+
check: deps _build _check
30+
31+
_style:
32+
pdm run ruff format $(checkfiles)
33+
pdm run ruff check --fix $(checkfiles)
34+
style: deps _style
35+
36+
_lint:
37+
pdm run ruff format $(checkfiles)
38+
pdm run ruff check --fix $(checkfiles)
39+
pdm run mypy $(checkfiles)
40+
lint: deps _build _lint
41+
42+
_test:
43+
pdm run pytest -s tests
44+
test: deps _test
45+
46+
_build:
47+
rm -fR dist/
48+
pdm build
49+
build: deps _build
50+
51+
# Usage::
52+
# make venv version=3.12
53+
venv:
54+
pdm venv create $(version)
55+
pdm run pip install --upgrade pip

pdm.lock

Lines changed: 60 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ classifiers = [
1919
"Programming Language :: Python :: 3.10",
2020
"Programming Language :: Python :: 3.11",
2121
"Programming Language :: Python :: 3.12",
22+
"Programming Language :: Python :: 3.13",
2223
]
2324

2425
[project.urls]
@@ -61,6 +62,11 @@ exclude = '''
6162

6263
[tool.ruff]
6364
line-length = 90
65+
src = ["src"]
66+
exclude = ["tests/fixtures"]
67+
target-version = "py38"
68+
69+
[tool.ruff.lint]
6470
select = [
6571
"B", # flake8-bugbear
6672
"C4", # flake8-comprehensions
@@ -72,14 +78,13 @@ select = [
7278
"YTT", # flake8-2020
7379
]
7480
extend-ignore = ["B018", "B019"]
75-
src = ["src"]
76-
exclude = ["tests/fixtures"]
77-
target-version = "py37"
7881

79-
[tool.ruff.mccabe]
82+
[tool.ruff.lint.mccabe]
8083
max-complexity = 10
8184

82-
[tool.ruff.isort]
85+
[tool.ruff.lint.isort]
8386
known-first-party = ["findpython"]
8487

85-
88+
[[tool.mypy.overrides]]
89+
module = "_winreg"
90+
ignore_missing_imports = true

src/findpython/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"""
2-
FindPython
3-
~~~~~~~~~~
4-
A utility to find python versions on your system
2+
FindPython
3+
~~~~~~~~~~
4+
A utility to find python versions on your system
55
"""
6+
67
from __future__ import annotations
78

89
from typing import TYPE_CHECKING, TypeVar
@@ -59,4 +60,4 @@ def register_provider(provider: P) -> P:
5960
return provider
6061

6162

62-
__all__ = ["Finder", "find", "find_all", "PythonVersion", "register_provider"]
63+
__all__ = ["Finder", "PythonVersion", "find", "find_all", "register_provider"]

src/findpython/pep514tools/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010

1111
from findpython.pep514tools.environment import find, findall, findone
1212

13-
__all__ = ["findall", "find", "findone"]
13+
__all__ = ["find", "findall", "findone"]

src/findpython/pep514tools/_registry.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: disable-error-code="attr-defined"
12
# -------------------------------------------------------------------------
23
# Copyright (c) Steve Dower
34
# All rights reserved.
@@ -6,10 +7,10 @@
67
# -------------------------------------------------------------------------
78

89
__all__ = [
9-
"open_source",
10+
"REGISTRY_SOURCE_CU",
1011
"REGISTRY_SOURCE_LM",
1112
"REGISTRY_SOURCE_LM_WOW6432",
12-
"REGISTRY_SOURCE_CU",
13+
"open_source",
1314
]
1415

1516
import re
@@ -18,7 +19,7 @@
1819
try:
1920
import winreg
2021
except ImportError:
21-
import _winreg as winreg
22+
import _winreg as winreg # type:ignore[no-redef]
2223

2324
REGISTRY_SOURCE_LM = 1
2425
REGISTRY_SOURCE_LM_WOW6432 = 2

src/findpython/pep514tools/environment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Distributed under the terms of the MIT License
66
# -------------------------------------------------------------------------
77

8-
__all__ = ["Environment", "findall", "find", "findone"]
8+
__all__ = ["Environment", "find", "findall", "findone"]
99

1010
import sys
1111

src/findpython/providers/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
This package contains all the providers for the pythonfinder module.
33
"""
4+
45
from __future__ import annotations
56

67
from findpython.providers.asdf import AsdfProvider

0 commit comments

Comments
 (0)