Skip to content

Commit d4fdc2d

Browse files
authored
feat: adding a pyproject formatter and running edgetest on the library (#93)
* feat: adding a pyproject formatter and running edgetest on the library * chore: changing maximum line length based on @jdawang's suggestion
1 parent fb767fb commit d4fdc2d

File tree

6 files changed

+197
-139
lines changed

6 files changed

+197
-139
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@ repos:
1515
hooks:
1616
- id: mypy
1717
exclude: ^(docs|tests)\/
18-
language_version: python3.9
18+
language_version: python3.10
1919
args: [--namespace-packages, --explicit-package-bases, --ignore-missing-imports, --non-interactive, --install-types]
2020
- repo: https://github.com/pre-commit/pre-commit-hooks
2121
rev: v4.4.0
2222
hooks:
2323
- id: trailing-whitespace
2424
- id: debug-statements
2525
- id: end-of-file-fixer
26+
- repo: https://github.com/tox-dev/pyproject-fmt
27+
rev: "v2.5.0"
28+
hooks:
29+
- id: pyproject-fmt

edgetest/interface.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import click
77
import pluggy
8+
import pyproject_fmt
89
from tomlkit import dumps
910

1011
from edgetest import hookspecs, lib
@@ -207,6 +208,8 @@ def cli(
207208
)
208209
with open(requirements, "w") as outfile:
209210
outfile.write(upgraded)
211+
# Run the formatter
212+
pyproject_fmt.run([config])
210213
else:
211214
click.echo(f"Overwriting the requirements file {requirements}...")
212215
upgraded = upgrade_requirements(

pyproject.toml

Lines changed: 134 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,160 @@
1+
[build-system]
2+
build-backend = "setuptools.build_meta"
3+
4+
requires = [
5+
"setuptools>=64.0.0",
6+
]
7+
18
[project]
29
name = "edgetest"
3-
requires-python = ">=3.8.0"
410
description = "Bleeding edge dependency testing"
11+
license = { text = "Apache Software License" }
512
authors = [
613
{ name = "Akshay Gupta", email = "[email protected]" },
714
{ name = "Faisal Dosani", email = "[email protected]" },
8-
{ name = "Jacob Dawang", email = "[email protected]" }
15+
{ name = "Jacob Dawang", email = "[email protected]" },
916
]
10-
license = {text = "Apache Software License"}
17+
requires-python = ">=3.8.0"
1118
classifiers = [
12-
"Intended Audience :: Developers",
13-
"Natural Language :: English",
14-
"Operating System :: OS Independent",
15-
"Programming Language :: Python",
16-
"Programming Language :: Python :: 3",
17-
"Programming Language :: Python :: 3 :: Only",
18-
"Programming Language :: Python :: 3.8",
19-
"Programming Language :: Python :: 3.9",
20-
"Programming Language :: Python :: 3.10",
21-
"Programming Language :: Python :: 3.11",
22-
"Programming Language :: Python :: 3.12",
19+
"Intended Audience :: Developers",
20+
"Natural Language :: English",
21+
"Operating System :: OS Independent",
22+
"Programming Language :: Python",
23+
"Programming Language :: Python :: 3 :: Only",
24+
"Programming Language :: Python :: 3.8",
25+
"Programming Language :: Python :: 3.9",
26+
"Programming Language :: Python :: 3.10",
27+
"Programming Language :: Python :: 3.11",
28+
"Programming Language :: Python :: 3.12",
2329
]
24-
dependencies = [
25-
"Cerberus<=1.3.7,>=1.3.0",
26-
"click<=8.1.8,>=7.0",
27-
"pluggy<=1.5.0,>=1.3.0",
28-
"tabulate<=0.9.0,>=0.8.9",
29-
"packaging<=24.2,>20.6",
30-
"tomlkit<=0.11.4,>=0.11.4",
31-
"uv<=0.6.5,>=0.2.0"
30+
dynamic = [
31+
"readme",
32+
"version",
3233
]
3334

34-
dynamic = ["readme", "version"]
35-
36-
[project.optional-dependencies]
37-
docs = ["furo", "sphinx", "sphinx-copybutton", "sphinx-tabs", "pillow", "recommonmark"]
38-
tests = ["coverage", "pytest", "pytest-cov"]
39-
qa = ["mypy", "pre-commit", "ruff~=0.5", "types-click", "types-setuptools", "types-tabulate"]
40-
build = ["build", "twine", "wheel", "bumpver"]
41-
dev = ["edgetest[docs]", "edgetest[tests]", "edgetest[qa]", "edgetest[build]"]
42-
43-
[project.urls]
44-
"Documentation" = "https://capitalone.github.io/edgetest/"
45-
"Bug Tracker" = "https://github.com/capitalone/edgetest/issues"
46-
"Source Code" = "https://github.com/capitalone/edgetest"
47-
48-
[project.scripts]
49-
edgetest = "edgetest.interface:cli"
50-
51-
# Build system
52-
[build-system]
53-
requires = ["setuptools>=64.0.0"]
54-
build-backend = "setuptools.build_meta"
35+
dependencies = [
36+
"cerberus>=1.3.0,<=1.3.7",
37+
"click>=7.0,<=8.2.0",
38+
"packaging>20.6,<=25.0",
39+
"pluggy>=1.3.0,<=1.6.0",
40+
"pyproject-fmt>=2.0.0,<=2.5.1",
41+
"tabulate>=0.8.9,<=0.9.0",
42+
"tomlkit<=0.11.4,>=0.11.4",
43+
"uv>=0.2.0,<=0.7.4",
44+
]
45+
optional-dependencies.build = [ "build", "bumpver", "twine", "wheel" ]
46+
optional-dependencies.dev = [
47+
"edgetest[build]",
48+
"edgetest[docs]",
49+
"edgetest[qa]",
50+
"edgetest[tests]",
51+
]
52+
optional-dependencies.docs = [
53+
"furo",
54+
"pillow",
55+
"recommonmark",
56+
"sphinx",
57+
"sphinx-copybutton",
58+
"sphinx-tabs",
59+
]
60+
optional-dependencies.qa = [
61+
"mypy",
62+
"pre-commit",
63+
"ruff~=0.5",
64+
"types-click",
65+
"types-setuptools",
66+
"types-tabulate",
67+
]
68+
optional-dependencies.tests = [ "coverage", "pytest", "pytest-cov" ]
5569

56-
##############################################################################
57-
# Setuptools configuration
58-
##############################################################################
70+
urls."Bug Tracker" = "https://github.com/capitalone/edgetest/issues"
71+
urls."Documentation" = "https://capitalone.github.io/edgetest/"
72+
urls."Source Code" = "https://github.com/capitalone/edgetest"
73+
scripts.edgetest = "edgetest.interface:cli"
5974

6075
[tool.setuptools]
6176
include-package-data = true
6277
zip-safe = false
6378

6479
[tool.setuptools.dynamic]
6580
version = { attr = "edgetest.__version__" }
66-
readme = { file = ["README.md"], content-type = "text/markdown" }
81+
readme = { file = [
82+
"README.md",
83+
], content-type = "text/markdown" }
6784

6885
##############################################################################
6986
# Tooling
7087
##############################################################################
7188

72-
# EDGETEST -------------------------------------------------------------------
89+
[tool.ruff]
90+
target-version = "py39"
91+
extend-include = [
92+
"*.ipynb",
93+
]
94+
lint.select = [
95+
"B", # flake8-bugbear
96+
"C", # flake8-comprehensions
97+
"D", # pydocstyle
98+
"E", # pycodestyle errors
99+
"F", # pyflakes
100+
"I", # isort
101+
"LOG", # flake8-logging
102+
"RUF", # Ruff errors
103+
"SIM", # flake8-simplify
104+
"T20", # flake8-print
105+
"TID252", # flake8-tidy-imports ban relative imports
106+
"UP", # pyupgrade
107+
"W", # pycodestyle warnings
108+
]
109+
lint.ignore = [
110+
"C901", # Add back in later
111+
"D206", # Docstring indentation. Using formatter instead.
112+
"D300", # Use triple single quotes. Using formatter instead.
113+
"E111", # Check indentation level. Using formatter instead.
114+
"E114", # Check indentation level. Using formatter instead.
115+
"E117", # Check indentation level. Using formatter instead.
116+
"E203", # Check whitespace. Using formatter instead.
117+
"E501", # Line too long. Using formatter instead.
118+
"SIM105", # Use ``contextlib.suppress(FileNotFoundError)`` insetad of try - execpt - pass.
119+
"SIM108", # Use ternary operator instead of if-else blocks.
120+
"UP006", # ``typing.x`` is deprecated, use ``x`` instead
121+
"UP035", # ``typing.x`` is deprecated, use ``x`` instead
122+
]
123+
lint.per-file-ignores."**/{tests,docs}/*" = [
124+
"ARG",
125+
"D",
126+
"E402",
127+
"F841",
128+
]
129+
lint.per-file-ignores."__init__.py" = [
130+
"E402",
131+
]
132+
lint.flake8-tidy-imports.ban-relative-imports = "all"
133+
lint.pydocstyle.convention = "numpy"
134+
lint.preview = true
135+
136+
[tool.pyproject-fmt]
137+
column_width = 88
138+
indent = 4
139+
keep_full_version = true
140+
max_supported_python = "3.12"
141+
142+
[tool.pytest.ini_options]
143+
markers = [
144+
"unit: mark unit tests that do not require external interfaces and use mocking",
145+
"integration: mark test that interact with an external system",
146+
]
147+
addopts = "--verbose"
148+
149+
[tool.mypy]
150+
python_version = "3.10"
151+
warn_return_any = true
152+
warn_unused_configs = true
153+
ignore_missing_imports = true
154+
allow_redefinition = true
155+
disable_error_code = "empty-body"
73156

74157
[edgetest.envs.core]
75-
python_version = "3.9"
76158
extras = [
77159
"tests",
78160
]
@@ -82,11 +164,11 @@ upgrade = [
82164
"pluggy",
83165
"tabulate",
84166
"packaging",
85-
"uv",
167+
"uv",
168+
"pyproject-fmt",
86169
]
87170

88171
[edgetest.envs.low]
89-
python_version = "3.9"
90172
extras = [
91173
"tests",
92174
]
@@ -96,11 +178,9 @@ lower = [
96178
"pluggy",
97179
"tabulate",
98180
"packaging",
99-
"uv",
181+
"uv",
100182
]
101183

102-
# BUMPVER --------------------------------------------------------------------
103-
104184
[bumpver]
105185
current_version = "2025.1.0"
106186
version_pattern = "YYYY.MM.INC0"
@@ -115,70 +195,3 @@ version_pattern = "YYYY.MM.INC0"
115195
"edgetest/__init__.py" = [
116196
'__version__ = "{version}"',
117197
]
118-
119-
# MYPY -----------------------------------------------------------------------
120-
121-
[tool.mypy]
122-
python_version = 3.9
123-
warn_return_any = true
124-
warn_unused_configs = true
125-
ignore_missing_imports = true
126-
allow_redefinition = true
127-
disable_error_code = "empty-body"
128-
129-
# PYTEST ---------------------------------------------------------------------
130-
131-
[tool.pytest.ini_options]
132-
markers = [
133-
"unit: mark unit tests that do not require external interfaces and use mocking",
134-
"integration: mark test that interact with an external system",
135-
]
136-
addopts = "--verbose"
137-
138-
# RUFF -----------------------------------------------------------------------
139-
140-
[tool.ruff]
141-
extend-include = ["*.ipynb"]
142-
target-version = "py39"
143-
144-
[tool.ruff.lint]
145-
preview = true
146-
select = [
147-
"E", # pycodestyle errors
148-
"W", # pycodestyle warnings
149-
"F", # pyflakes
150-
"D", # pydocstyle
151-
"I", # isort
152-
"UP", # pyupgrade
153-
"B", # flake8-bugbear
154-
"C", # flake8-comprehensions
155-
"T20", # flake8-print
156-
"TID252", # flake8-tidy-imports ban relative imports
157-
"SIM", # flake8-simplify
158-
"LOG", # flake8-logging
159-
"RUF", # Ruff errors
160-
]
161-
ignore = [
162-
"C901", # Add back in later
163-
"E111", # Check indentation level. Using formatter instead.
164-
"E114", # Check indentation level. Using formatter instead.
165-
"E117", # Check indentation level. Using formatter instead.
166-
"E203", # Check whitespace. Using formatter instead.
167-
"E501", # Line too long. Using formatter instead.
168-
"D206", # Docstring indentation. Using formatter instead.
169-
"D300", # Use triple single quotes. Using formatter instead.
170-
"SIM108", # Use ternary operator instead of if-else blocks.
171-
"SIM105", # Use ``contextlib.suppress(FileNotFoundError)`` insetad of try - execpt - pass.
172-
"UP035", # ``typing.x`` is deprecated, use ``x`` instead
173-
"UP006", # ``typing.x`` is deprecated, use ``x`` instead
174-
]
175-
176-
[tool.ruff.lint.per-file-ignores]
177-
"__init__.py" = ["E402"]
178-
"**/{tests,docs}/*" = ["E402", "D", "F841", "ARG"]
179-
180-
[tool.ruff.lint.flake8-tidy-imports]
181-
ban-relative-imports = "all"
182-
183-
[tool.ruff.lint.pydocstyle]
184-
convention = "numpy"

requirements.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ packaging==24.2
88
# via edgetest (pyproject.toml)
99
pluggy==1.5.0
1010
# via edgetest (pyproject.toml)
11+
pyproject-fmt==2.5.1
12+
# via edgetest (pyproject.toml)
1113
tabulate==0.9.0
1214
# via edgetest (pyproject.toml)
15+
toml-fmt-common==1.0.1
16+
# via pyproject-fmt
17+
tomli==2.2.1
18+
# via toml-fmt-common
1319
tomlkit==0.11.4
1420
# via edgetest (pyproject.toml)
1521
uv==0.6.5

tests/test_integration_toml.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ def test_toy_package_extras():
194194
with open("pyproject.toml") as buf:
195195
config = load(buf)
196196

197-
assert "Scikit_Learn" in config["project"]["dependencies"][0]
198-
assert "Polars[pyarrow]" in config["project"]["dependencies"][1]
197+
assert "polars[pyarrow]" in config["project"]["dependencies"][0]
198+
assert "scikit-learn" in config["project"]["dependencies"][1]
199199
assert config["edgetest"]["envs"]["core"]["extras"] == ["tests"]
200200
assert config["edgetest"]["envs"]["core"]["upgrade"] == [
201201
"scikit-learn",

0 commit comments

Comments
 (0)