-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathpyproject.toml
More file actions
246 lines (209 loc) · 7.87 KB
/
pyproject.toml
File metadata and controls
246 lines (209 loc) · 7.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
################################################################################
# Build Configuration
################################################################################
[build-system]
build-backend = "hatchling.build"
requires = ["hatchling", "hatch-vcs"]
################################################################################
# Project Configuration
################################################################################
[project]
name = "pyospackage"
# You can chose to use dynamic versioning with hatch or static where you add it manually.
dynamic = ["version"]
description = "A package that adds numbers together."
authors = [
{ name = "Leah Wasser", email = "leah@pyopensci.org" },
]
license = "MIT"
requires-python = ">= 3.11" # Adjust based on the minimum version of Python that you support
readme = {"file" = "README.md", "content-type" = "text/markdown"}
# Please consult https://pypi.org/classifiers/ for a full list.
classifiers = [
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Typing :: Typed",
]
keywords = ["packaging"]
dependencies = [
"numpy>=2.2.6",
"requests>=2.32.5",
]
[project.urls]
Homepage = "https://github.com/pyopensci/pyospackage"
"Source Code" = "https://github.com/pyopensci/pyospackage"
"Bug Tracker" = "https://github.com/pyopensci/pyospackage/issues"
Documentation = "https://pyospackage.readthedocs.io"
Download = "https://pypi.org/project/pyospackage/#files"
[project.optional-dependencies]
dev = [
"pre-commit",
"ruff>=0.14.3",
]
tests = [
"pytest>=8.4.2",
]
docs = [
"sphinx>=8.2.3",
"myst-parser>=4.0.1",
"pydata-sphinx-theme~=0.16",
"sphinx-autobuild>=2024.10.3", # Add to template
"sphinx-autoapi>=3.6.0", # Add to template
"sphinx-design>=0.6.1", # Add to template
"sphinx-copybutton>=0.5.2", # Add to template
]
################################################################################
# Tool Configuration
################################################################################
# Hatch is building your package's wheel and sdist
# This tells hatch to only include Python packages (i.e., folders with __init__.py) in the build.
# read more about package building, here:
# https://www.pyopensci.org/python-package-guide/package-structure-code/python-package-distribution-files-sdist-wheel.html
[tool.hatch.build]
only-packages = true
# This tells Hatch to build the package from the src/me directory.
# Read more about src layouts here: https://www.pyopensci.org/python-package-guide/package-structure-code/python-package-structure.html
[tool.hatch.build.targets.wheel]
packages = ["src/pyospackage"]
[tool.hatch.build.hooks.vcs]
version-file = "src/pyospackage/_version.py"
[tool.hatch.version]
source = "vcs"
######## Configure pytest for your test suite ########
[tool.pytest.ini_options]
testpaths = ["tests"] # Tells pytest what directory tests are in
markers = ["raises"] # Tells pytest to not raise a warning if you use @pytest.mark.raises
[tool.coverage.paths]
source = [
"src/pyospackage",
"*/site-packages/pyospackage",
]
[tool.coverage.run]
# Ensures code coverage is measured for branches (conditional statements with different outcomes) in your code.
branch = true
parallel = true
omit = [
"src/pyospackage/_version.py",
]
[tool.coverage.report]
# This configures the output test coverage report
exclude_lines = ["pragma: no cover"]
precision = 2
[tool.ruff]
line-length = 88
[tool.ruff.lint]
select = ["ALL"]
ignore = [
"D107", # 'Missing docstring in __init__' ignored because pydoclint wants us to document the class instead.
"D203", # '1 blank line required before class docstring' ignored because we want no blank line.
"D212", # 'Multi-line docstring summary should start at the first line' ignored because we want the summary to start on the second line.
"D407", # 'Missing dashed underline after section' ignored because Google style docstrings don't underline.
"D413", # 'Missing blank line after section' ignored .
"D401", # 'First line should be in imperative mood' ignored
"ANN001", # Missing type annotation for {arg} in function" ignored
"ANN201", # 'Missing type annotation for {return}'.
"COM812", # 'Missing trailing comma in collection' ignored to comply with black formatting.
]
exclude = [
"src/pyospackage/_version.py",
"docs/conf.py",
]
[tool.ruff.lint.extend-per-file-ignores]
"__init__.py" = [
"E401", # 'Multiple imports on one line'
"E402", # 'Module level import not at top of file'
"F401", # 'Imported but unused'
"I001", # 'Import block is un-sorted or un-formatted' ignored because we may have to import in a particular, not-alphabetical order.
]
"tests/**/*.py" = [
"S101", # 'Use of assert detected' ignored because we are using pytest.
"INP001", # 'Insecure input' ignored because we are testing.
"ANN201", # 'Missing type annotation for {return}' ignored because all tests return `None`.
]
[tool.ruff.lint.isort]
case-sensitive = true
known-first-party = ["src", "pyospackage"]
[tool.pydoclint]
style = "numpy"
arg-type-hints-in-signature = true
arg-type-hints-in-docstring = true
check-return-types = false
check-yield-types = false
exclude = "_version.py"
# Use UV to create Hatch environments
[tool.hatch.envs.default]
installer = "uv"
################################################################################
# Hatch Environments
################################################################################
#--------------- Build and check your package ---------------#
# This table installs the tools you need to test and build your package
# `builder = true` needed since hatch 1.16: https://github.com/pypa/hatch/issues/2113
[tool.hatch.envs.build]
description = """Test the installation the package."""
dependencies = [
"pip",
"twine",
]
detached = true
builder = true
# This table installs created the command hatch run install:check which will build and check your package.
[tool.hatch.envs.build.scripts]
check = [
"pip check",
"hatch build {args:--clean}",
"twine check dist/*",
]
#--------------- Run tests ---------------#
[tool.hatch.envs.test]
description = """Run the test suite."""
extra-dependencies = [
"pytest",
"pytest-cov",
"pytest-raises",
"pytest-randomly",
"pytest-xdist",
]
[[tool.hatch.envs.test.matrix]]
python = ["3.11", "3.12", "3.13"]
[tool.hatch.envs.test.scripts]
run = "pytest {args:--cov=pyospackage --cov-report=term-missing}"
#--------------- Build and preview your documentation ---------------#
# This sets up a hatch environment with associated dependencies that need to be installed
[tool.hatch.envs.docs]
description = """Build or serve the documentation."""
python = "3.11"
# Install optional dependency test for docs
features = [
"docs",
]
# This table contains the scripts that you can use to build and serve your docs
# hatch run docs:build will build your documentation
# hatch run docs:serve will serve them 'live' on your computer locally
[tool.hatch.envs.docs.scripts]
build = ["sphinx-build {args:-W -b html docs docs/_build}"]
serve = ["sphinx-autobuild docs --watch src/pyospackage {args:-b html docs/_build/serve}"]
#--------------- Format & style your code ---------------#
[tool.hatch.envs.style]
description = """Check the style of the codebase."""
dependencies = [
"pydoclint",
"ruff",
]
detached = true
[tool.hatch.envs.style.scripts]
docstrings = "pydoclint src/ tests/"
code = "ruff check {args}"
format = "ruff format {args}"
check = ["docstrings", "code"]
#--------------- Check security for your dependencies ---------------#
[tool.hatch.envs.audit]
description = """Check dependencies for security vulnerabilities."""
extra-dependencies = [
"pip-audit",
]
[tool.hatch.envs.audit.scripts]
check = ["pip-audit"]