Skip to content

Commit 7ff0999

Browse files
authored
Merge pull request #1 from franneck94/updateToProjectToml
Update to project toml
2 parents a02b37a + d516251 commit 7ff0999

13 files changed

+248
-194
lines changed

.editorconfig

-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ end_of_line = lf
1212
[*.md]
1313
trim_trailing_whitespace = false
1414

15-
[mkdocs.yml]
16-
indent_size = 2
17-
1815
[Makefile]
1916
indent_style = tab
2017
trim_trailing_whitespace = false

.gitignore

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
################################
22
########### FILES ############
33
################################
4-
cython_computations.c
4+
*.exe
55

66
################################
77
########### FOLDERS ############
@@ -11,7 +11,13 @@ html/
1111
.benchmarks/
1212
reports/
1313
lectures/
14-
.mypy_cache/
14+
logs/
15+
models/
16+
ressources/
17+
.ruff_cache
18+
data/*.h5
19+
venv/
20+
.venv/
1521

1622
################################
1723
########### PYTHON #############

.pre-commit-config.yaml

+10-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repos:
1111
- id: check-toml
1212

1313
- repo: https://github.com/MarcoGorelli/cython-lint
14-
rev: v0.13.0
14+
rev: v0.15.0
1515
hooks:
1616
- id: cython-lint
1717
- id: double-quote-cython-strings
@@ -23,13 +23,18 @@ repos:
2323
exclude: ^docs/
2424

2525
- repo: https://github.com/psf/black
26-
rev: 23.1.0
26+
rev: 23.3.0
2727
hooks:
2828
- id: black
2929
exclude: ^docs/
3030

31-
- repo: https://github.com/PyCQA/flake8
32-
rev: 6.0.0
31+
- repo: https://github.com/charliermarsh/ruff-pre-commit
32+
rev: 'v0.0.261'
3333
hooks:
34-
- id: flake8
34+
- id: ruff
35+
36+
- repo: https://github.com/pre-commit/mirrors-mypy
37+
rev: v1.2.0
38+
hooks:
39+
- id: mypy
3540
exclude: ^docs/

README.md

+9-8
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,15 @@
1111
This is a template for Python projects. What you get:
1212

1313
- Source code and test code is seperated in different directories.
14-
- External libraries installed and managed by [Pip](https://pypi.org/project/pip/).
15-
- Setup for tests using [Pytest](https://docs.pytest.org/en/stable/).
16-
- Continuous testing with [Github-Actions](https://github.com/features/actions/).
14+
- External libraries installed and managed by [Pip](https://pypi.org/project/pip/) and [setuptools](https://setuptools.pypa.io/en/latest/) in a pyproject.toml.
15+
- Setup for tests using [Pytest](https://docs.pytest.org/en/stable/) and coverage with [Pytest-Cov](https://github.com/pytest-dev/pytest-cov).
16+
- Continuous testing with [Github-Actions](https://github.com/features/actions/) including [pre-commit](https://github.com/pre-commit/pre-commit).
1717
- Code coverage reports, including automatic upload to [Codecov](https://codecov.io).
1818
- Code documentation with [Mkdocs](https://www.mkdocs.org/).
19-
- Optional: Use of [VSCode](https://code.visualstudio.com/) with the Python and UnitTest extension.
2019

2120
## Structure
2221

2322
``` text
24-
├── setup.py
25-
├── setup.cfg
2623
├── pyproject.toml
2724
├── ... other config files ...
2825
├── tests
@@ -44,12 +41,16 @@ This is a template for Python projects. What you get:
4441

4542
```bash
4643
# Build and Install (local)
47-
pip install -e .
44+
pip install -e . # OR
45+
pip install -e ../Python-Project-Template # OR
46+
pip install -e ../Python-Project-Template[all]
4847
```
4948

5049
```bash
5150
# Test
52-
pytest tests
51+
pytest tests # OR
52+
pytest . # OR
53+
pytest
5354
```
5455

5556
```bash

examples/main.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import fastvector
2+
3+
4+
def main() -> None:
5+
V1 = fastvector.Vector2D(-1, 1)
6+
V2 = fastvector.Vector2D(2.5, -2.5)
7+
print(V1 - V2)
8+
9+
10+
if __name__ == "__main__":
11+
main()

fastvector/vector.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from functools import total_ordering
55
from math import sqrt
66
from typing import SupportsFloat
7-
from typing import Union
87

98

109
@total_ordering
@@ -108,8 +107,8 @@ def __sub__(self, other_vector: Vector2D) -> Vector2D:
108107
return Vector2D(x, y)
109108

110109
def __mul__(
111-
self, other: Union[Vector2D, SupportsFloat]
112-
) -> Union[Vector2D, SupportsFloat]:
110+
self, other: Vector2D | SupportsFloat
111+
) -> Vector2D | SupportsFloat:
113112
"""Return the multiplication of self and the other vector/number.
114113
115114
Args:

fastvector/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "4.0.0"
1+
__version__ = "5.0.0"

pyproject.toml

+193-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,199 @@
1+
[build-system]
2+
requires = [
3+
"setuptools",
4+
"setuptools-scm",
5+
# wheel, # wheel only needed if you explicitly access it during build time
6+
]
7+
build-backend = "setuptools.build_meta"
8+
9+
[project]
10+
name = "fastvector"
11+
authors = [
12+
{name = "Jan Schaffranek", email = "[email protected]"},
13+
]
14+
description = "This is a simple vector python package."
15+
license = {file = "LICENSE"}
16+
requires-python = ">=3.9"
17+
classifiers = [
18+
"Programming Language :: Python :: 3",
19+
"Programming Language :: Python :: 3",
20+
"Programming Language :: Python :: 3.9",
21+
"Programming Language :: Python :: 3.10",
22+
"Programming Language :: Python :: 3.11",
23+
"Operating System :: Microsoft :: Windows",
24+
"Operating System :: POSIX :: Linux",
25+
"Operating System :: POSIX",
26+
"Operating System :: Unix",
27+
"Operating System :: MacOS",
28+
]
29+
dependencies = [
30+
"requests",
31+
"importlib-metadata; python_version<'3.8'",
32+
"numpy>=1.21.6; python_version<'3.11'",
33+
"numpy>=1.23.2; python_version>='3.11'",
34+
]
35+
dynamic = ["version", "readme"]
36+
37+
[project.optional-dependencies]
38+
test = [
39+
"pytest",
40+
"pytest-cov",
41+
"codecov",
42+
"pre-commit",
43+
]
44+
doc = [
45+
"mkdocs",
46+
"mkdocstrings",
47+
"mkdocstrings[python]",
48+
"mkdocs-material",
49+
"Pygments",
50+
]
51+
dev = [
52+
"black",
53+
"isort",
54+
"mypy",
55+
"pre-commit",
56+
"ruff",
57+
]
58+
all = ["fastvector[test,doc,dev]"]
59+
60+
[tool.setuptools]
61+
platforms = ["unix", "linux", "osx", "cygwin", "win32"]
62+
packages = ["fastvector"] # optional
63+
64+
[tool.setuptools.dynamic]
65+
version = {attr = "fastvector.__version__"}
66+
readme = {file = ["README.md"]}
67+
68+
[tool.pytest.ini_options]
69+
minversion = "7.3"
70+
testpaths = "tests"
71+
72+
[tool.coverage.run]
73+
branch = true
74+
parallel = true
75+
omit = [
76+
"setup.py",
77+
"fastvector/__init__.py",
78+
"fastvector/version.py",
79+
]
80+
81+
[tool.coverage.report]
82+
exclude_lines = [
83+
"pragma: no cover",
84+
"def __repr__",
85+
"if self.debug",
86+
"raise AssertionError",
87+
"raise NotImplementedError",
88+
"if __name__ == .__main__.:",
89+
"raise AssertionError",
90+
"raise NotImplementedError",
91+
]
92+
93+
[tool.coverage.paths]
94+
source = [
95+
"fastvector/*",
96+
]
97+
98+
[tool.coverage.html]
99+
directory = "reports"
100+
101+
######## Tools
102+
1103
[tool.black]
2104
line-length = 80
3105
skip-string-normalization = false
4106
skip-magic-trailing-comma = false
107+
exclude = '''
108+
(
109+
asv_bench/env
110+
| \.egg
111+
| \.git
112+
| \.mypy_cache
113+
| \.tox
114+
| \.venv
115+
| build
116+
| setup.py
117+
)
118+
'''
5119

6-
[build-system]
7-
requires = ["setuptools>=45.0", "setuptools_scm[toml]>=6.3.1", "wheel"]
8-
build-backend = "setuptools.build_meta"
9-
10-
[tool.pytest.ini_options]
11-
testpaths = [
12-
"tests"
120+
[tool.isort]
121+
sections = [
122+
"FUTURE",
123+
"STDLIB",
124+
"THIRDPARTY",
125+
"FIRSTPARTY",
126+
"LOCALFOLDER"
127+
]
128+
default_section = "FIRSTPARTY"
129+
known_third_party = [
130+
"numpy",
131+
"pandas",
132+
"keras",
133+
"tensorflow",
134+
"sklearn",
135+
"matplotlib",
136+
"scipy",
137+
"h5py",
138+
"seaborn",
139+
"numba",
140+
"gym",
141+
"PyQt6",
142+
"PyQt5",
143+
"pyqtgraph"
13144
]
145+
multi_line_output = 3
146+
lines_after_imports = 2
147+
force_single_line = true
148+
use_parentheses = true
149+
ensure_newline_before_comments = true
150+
line_length = 80
151+
152+
[tool.mypy]
153+
warn_return_any = true
154+
warn_unused_configs = true
155+
ignore = []
156+
follow_imports = "silent"
157+
check_untyped_defs = true
158+
disallow_incomplete_defs = true
159+
disallow_untyped_defs = true
160+
disallow_subclassing_any = true
161+
strict_optional = true
162+
no_implicit_optional = true
163+
warn_no_return = true
164+
warn_unreachable = true
165+
allow_untyped_globals = false
166+
allow_redefinition = false
167+
local_partial_types = false
168+
implicit_reexport = true
169+
strict_equality = true
170+
171+
[tool.ruff]
172+
select = ["F", "E"]
173+
extend-select = ["W", "I002", "B", "UP", "PLE", "PLW", "NPY", "RUF", "PD", "SIM", "PT"]
174+
unfixable = ["NPY002"]
175+
ignore = []
176+
fixable = ["E", "F", "W", "I", "B", "UP", "PLE", "PLW", "NPY", "RUF", "PD", "SIM", "PT"]
177+
target-version = "py39"
178+
179+
line-length = 80
180+
extend-exclude = ["tests", "test"]
181+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
182+
183+
[tool.ruff.isort]
184+
force-single-line = true
185+
force-sort-within-sections = false
186+
lines-after-imports = 2
187+
188+
[tool.ruff.mccabe]
189+
max-complexity = 10
190+
191+
[tool.ruff.pycodestyle]
192+
ignore-overlong-task-comments = true
193+
194+
[tool.ruff.pydocstyle]
195+
convention = "numpy"
196+
197+
[tool.ruff.flake8-annotations]
198+
allow-star-arg-any = false
199+
ignore-fully-untyped = false

requirements-dev.txt

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
# Runtime requirements
22
--requirement requirements.txt
33

4+
build
5+
setuptools>=67.7.1
6+
47
# Testing
58
pytest
69
codecov
710
pytest-cov
811
pre-commit
912

1013
# Linting/Tooling
11-
pylint
12-
flake8
13-
mypy
14-
isort
15-
black
16-
pre-commit
17-
autopep8
14+
black>=23.3.0
15+
isort>=5.12.0
16+
mypy>=1.2.0
17+
pre-commit>=3.2.2
18+
ruff>=0.0.262
1819

1920
# Documentation
2021
mkdocs

0 commit comments

Comments
 (0)