Skip to content

Commit 94b0ae1

Browse files
Modernize project tooling and align urllib3 usage with best practices (#13)
* Modernize project tooling and align urllib3 usage with best practices Migrate build configuration from setup.cfg/setup.py/ruff.toml into a single pyproject.toml. Adopt uv as the package manager, replacing pip in the Makefile and GitHub Actions workflows. Upgrade minimum Python version from 3.9 (EOL) to 3.10 and add 3.13 to the CI matrix. Integrate Astral's ty static type checker, modernize type hints to Python 3.10+ syntax (X | None, dict, list, tuple), and resolve all 32 reported diagnostics across source and test files. Fix several urllib3 issues identified against current best practices: - Bug: delete() used self.host + uri instead of the normalised url - Bug: auth.py status range < 499 excluded valid 499 client errors - Set cert_reqs explicitly so verify_ssl=False actually disables TLS - Replace global urllib3.request() in auth.py with per-instance PoolManager to avoid shared side effects - Use urllib3.make_headers() for basic auth encoding in core.py - Add allowed_methods to Retry so POST/PATCH operations are retried Co-authored-by: Cursor <cursoragent@cursor.com> * Update SonarQube scan action from v4 to v6 v4 is no longer supported and contains a security vulnerability per the deprecation notice from SonarSource. Co-authored-by: Cursor <cursoragent@cursor.com> * Bump version to 1.5.0 Minor version bump for dropping Python 3.9 support, modernized tooling (pyproject.toml, uv, ty), and urllib3 best-practice fixes. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent d86b89e commit 94b0ae1

17 files changed

Lines changed: 1412 additions & 288 deletions

File tree

.github/workflows/development.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ jobs:
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
17-
python-version: ["3.9", "3.10", "3.11", "3.12"]
17+
python-version: ["3.10", "3.11", "3.12", "3.13"]
1818
steps:
19-
- uses: actions/checkout@v3
19+
- uses: actions/checkout@v4
2020
with:
2121
fetch-depth: 0 # Disabling shallow clone for SonarCloud
2222

23-
- name: Set up Python ${{ matrix.python-version }}
24-
uses: actions/setup-python@v4
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v5
2525
with:
2626
python-version: ${{ matrix.python-version }}
2727

@@ -31,12 +31,19 @@ jobs:
3131
- name: Code Linting
3232
run: make lint
3333

34+
- name: Code Formatting
35+
run: make format
36+
37+
- name: Type Checking
38+
run: make typecheck
39+
3440
- name: Code Testing
41+
if: matrix.python-version == '3.10'
3542
run: make test-report
3643

3744
- name: SonarQube Scan
38-
if: matrix.python-version == '3.9'
39-
uses: SonarSource/sonarqube-scan-action@v4
45+
if: matrix.python-version == '3.10'
46+
uses: SonarSource/sonarqube-scan-action@v6
4047
env:
4148
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4249
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

.github/workflows/release.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,10 @@ jobs:
1515
permissions:
1616
id-token: write
1717
steps:
18-
- uses: actions/checkout@v3
19-
- uses: actions/setup-python@v4
20-
with:
21-
python-version: "3.x"
22-
- name: deps
23-
run: python -m pip install -U build
24-
- name: build
25-
run: python -m build
18+
- uses: actions/checkout@v4
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v5
21+
- name: Build package
22+
run: uv build
2623
- name: Publish package distributions to PyPI
2724
uses: pypa/gh-action-pypi-publish@release/v1

Makefile

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,34 @@ help: # Displays the help menu with all the targets
44
done
55

66
apidocs: # Creates API documentation for RTDs
7-
@sphinx-apidoc -f -o docs cruds/
7+
@uv run sphinx-apidoc -f -o docs cruds/
88

9-
develop: update-pip # Installs all requirements and testing requirements
10-
@python -m pip install -e '.[develop]' \
11-
&& pre-commit install
9+
develop: # Installs all requirements and testing requirements
10+
@uv sync --group dev \
11+
&& uv run pre-commit install
1212

1313
test: # Perform unit testing on the source code
14-
@python -m pytest -vvv
14+
@uv run pytest -vvv
1515

1616
test-report: # Perform unit testing on the source code with a coverage report
17-
@python -m pytest --cov-report=xml
17+
@uv run pytest --cov-report=xml
1818

1919
lint: # Quality checks on the source code (Doesn't change code)
20-
@python -m ruff check --diff src/
20+
@uv run ruff check --diff src/
2121

2222
format: # Check the format of source code (Doesn't change code)
23-
@python -m ruff format --diff src/
23+
@uv run ruff format --diff src/
2424

25-
update-pip: # Updates the version of pip
26-
@python -m pip install --upgrade pip
25+
typecheck: # Static type checking on the source code
26+
@uv run ty check
2727

2828
uninstall: clean
29-
@pip uninstall -y cruds
29+
@uv pip uninstall cruds
3030

3131
clean: # Removes built Python Packages and cached byte code
32-
@python -c "from setuptools import setup; setup()" clean --all;\
33-
find $(PACKAGES) -type d -name __pycache__ -prune -exec rm -rfv {} \;;\
34-
find $(PACKAGES) -type d -name '*.egg-info' -prune -exec rm -rfv {} \;;\
32+
@find . -type d -name __pycache__ -prune -exec rm -rfv {} \;;\
33+
find . -type d -name '*.egg-info' -prune -exec rm -rfv {} \;;\
3534
echo "clean completed"
3635

3736
.DEFAULT_GOAL := help
38-
.PHONY: help apidocs develop test test-report lint format update-pip uninstall clean
37+
.PHONY: help apidocs develop test test-report lint format typecheck uninstall clean

pyproject.toml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
[build-system]
2+
requires = ["setuptools>=68.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "cruds"
7+
dynamic = ["version"]
8+
description = "CRUDs is a high level library for API's, and is ideal for automation system and/or interactive environments like Notebooks"
9+
readme = "README.md"
10+
license = "MIT"
11+
requires-python = ">=3.10"
12+
authors = [{name = "John Brandborg", email = "john.brandborg+pypi@pm.me"}]
13+
keywords = ["rest", "api", "crud", "http", "https", "planhat"]
14+
classifiers = [
15+
"Development Status :: 5 - Production/Stable",
16+
"Intended Audience :: Developers",
17+
"Environment :: Console",
18+
"Operating System :: MacOS :: MacOS X",
19+
"Operating System :: Microsoft :: Windows",
20+
"Operating System :: POSIX",
21+
"Programming Language :: Python :: 3",
22+
"Programming Language :: Python :: 3 :: Only",
23+
"Programming Language :: Python :: 3.10",
24+
"Programming Language :: Python :: 3.11",
25+
"Programming Language :: Python :: 3.12",
26+
"Programming Language :: Python :: 3.13",
27+
"Topic :: Software Development :: Libraries",
28+
"Topic :: Utilities",
29+
]
30+
dependencies = [
31+
"certifi>=2024.2.2",
32+
"urllib3>=2.5.0,<3.0.0",
33+
"PyYAML>=6.0.1,<7.0.0",
34+
"jsonschema>=4.21.1,<5.0.0",
35+
]
36+
37+
[project.urls]
38+
Changelog = "http://cruds.readthedocs.io/en/stable/changelog.html"
39+
Documentation = "http://cruds.readthedocs.io/en/stable"
40+
Source = "https://github.com/johnbrandborg/cruds"
41+
Tracker = "https://github.com/johnbrandborg/cruds/issues"
42+
43+
[project.optional-dependencies]
44+
rtd = ["sphinx"]
45+
46+
[dependency-groups]
47+
dev = [
48+
"pre-commit",
49+
"pytest",
50+
"pytest-cov",
51+
"ruff",
52+
"ty",
53+
]
54+
55+
[tool.setuptools.dynamic]
56+
version = {attr = "cruds.__version__"}
57+
58+
[tool.setuptools.packages.find]
59+
where = ["src"]
60+
61+
[tool.setuptools.package-data]
62+
"*" = ["*.yml", "*.yaml"]
63+
64+
[tool.ruff]
65+
line-length = 88
66+
indent-width = 4
67+
target-version = "py310"
68+
69+
[tool.ruff.lint]
70+
select = ["E4", "E7", "E9", "F"]
71+
ignore = []
72+
fixable = ["ALL"]
73+
unfixable = []
74+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
75+
76+
[tool.ruff.format]
77+
quote-style = "double"
78+
indent-style = "space"
79+
skip-magic-trailing-comma = false
80+
line-ending = "auto"
81+
docstring-code-format = false
82+
docstring-code-line-length = "dynamic"
83+
84+
[tool.ty.environment]
85+
python-version = "3.10"
86+
87+
[tool.ty.src]
88+
include = ["src/", "tests/"]
89+
90+
[tool.ty.terminal]
91+
error-on-warning = false
92+
93+
[tool.pytest.ini_options]
94+
addopts = "--cov=src/ tests/"
95+
96+
[tool.coverage.run]
97+
branch = true
98+
relative_files = true
99+
omit = [
100+
"env/*",
101+
".env/*",
102+
"venv/*",
103+
"tests/*",
104+
]
105+
106+
[tool.coverage.xml]
107+
output = "coverage.xml"
108+
109+
[tool.coverage.report]
110+
show_missing = true
111+
exclude_lines = [
112+
"^if __name__ ==",
113+
"^\\s*except KeyboardInterrupt",
114+
"@abc.abstractmethod",
115+
]

ruff.toml

Lines changed: 0 additions & 77 deletions
This file was deleted.

setup.cfg

Lines changed: 0 additions & 85 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)