Skip to content

Commit

Permalink
Merge pull request #1 from franneck94/updateToProjectToml
Browse files Browse the repository at this point in the history
Update to project toml
  • Loading branch information
franneck94 authored Apr 24, 2023
2 parents a02b37a + d516251 commit 7ff0999
Show file tree
Hide file tree
Showing 13 changed files with 248 additions and 194 deletions.
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ end_of_line = lf
[*.md]
trim_trailing_whitespace = false

[mkdocs.yml]
indent_size = 2

[Makefile]
indent_style = tab
trim_trailing_whitespace = false
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
################################
########### FILES ############
################################
cython_computations.c
*.exe

################################
########### FOLDERS ############
Expand All @@ -11,7 +11,13 @@ html/
.benchmarks/
reports/
lectures/
.mypy_cache/
logs/
models/
ressources/
.ruff_cache
data/*.h5
venv/
.venv/

################################
########### PYTHON #############
Expand Down
15 changes: 10 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
- id: check-toml

- repo: https://github.com/MarcoGorelli/cython-lint
rev: v0.13.0
rev: v0.15.0
hooks:
- id: cython-lint
- id: double-quote-cython-strings
Expand All @@ -23,13 +23,18 @@ repos:
exclude: ^docs/

- repo: https://github.com/psf/black
rev: 23.1.0
rev: 23.3.0
hooks:
- id: black
exclude: ^docs/

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.261'
hooks:
- id: flake8
- id: ruff

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.2.0
hooks:
- id: mypy
exclude: ^docs/
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,15 @@
This is a template for Python projects. What you get:

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

## Structure

``` text
├── setup.py
├── setup.cfg
├── pyproject.toml
├── ... other config files ...
├── tests
Expand All @@ -44,12 +41,16 @@ This is a template for Python projects. What you get:

```bash
# Build and Install (local)
pip install -e .
pip install -e . # OR
pip install -e ../Python-Project-Template # OR
pip install -e ../Python-Project-Template[all]
```

```bash
# Test
pytest tests
pytest tests # OR
pytest . # OR
pytest
```

```bash
Expand Down
11 changes: 11 additions & 0 deletions examples/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import fastvector


def main() -> None:
V1 = fastvector.Vector2D(-1, 1)
V2 = fastvector.Vector2D(2.5, -2.5)
print(V1 - V2)


if __name__ == "__main__":
main()
5 changes: 2 additions & 3 deletions fastvector/vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from functools import total_ordering
from math import sqrt
from typing import SupportsFloat
from typing import Union


@total_ordering
Expand Down Expand Up @@ -108,8 +107,8 @@ def __sub__(self, other_vector: Vector2D) -> Vector2D:
return Vector2D(x, y)

def __mul__(
self, other: Union[Vector2D, SupportsFloat]
) -> Union[Vector2D, SupportsFloat]:
self, other: Vector2D | SupportsFloat
) -> Vector2D | SupportsFloat:
"""Return the multiplication of self and the other vector/number.
Args:
Expand Down
2 changes: 1 addition & 1 deletion fastvector/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "4.0.0"
__version__ = "5.0.0"
200 changes: 193 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,199 @@
[build-system]
requires = [
"setuptools",
"setuptools-scm",
# wheel, # wheel only needed if you explicitly access it during build time
]
build-backend = "setuptools.build_meta"

[project]
name = "fastvector"
authors = [
{name = "Jan Schaffranek", email = "[email protected]"},
]
description = "This is a simple vector python package."
license = {file = "LICENSE"}
requires-python = ">=3.9"
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Operating System :: POSIX",
"Operating System :: Unix",
"Operating System :: MacOS",
]
dependencies = [
"requests",
"importlib-metadata; python_version<'3.8'",
"numpy>=1.21.6; python_version<'3.11'",
"numpy>=1.23.2; python_version>='3.11'",
]
dynamic = ["version", "readme"]

[project.optional-dependencies]
test = [
"pytest",
"pytest-cov",
"codecov",
"pre-commit",
]
doc = [
"mkdocs",
"mkdocstrings",
"mkdocstrings[python]",
"mkdocs-material",
"Pygments",
]
dev = [
"black",
"isort",
"mypy",
"pre-commit",
"ruff",
]
all = ["fastvector[test,doc,dev]"]

[tool.setuptools]
platforms = ["unix", "linux", "osx", "cygwin", "win32"]
packages = ["fastvector"] # optional

[tool.setuptools.dynamic]
version = {attr = "fastvector.__version__"}
readme = {file = ["README.md"]}

[tool.pytest.ini_options]
minversion = "7.3"
testpaths = "tests"

[tool.coverage.run]
branch = true
parallel = true
omit = [
"setup.py",
"fastvector/__init__.py",
"fastvector/version.py",
]

[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"def __repr__",
"if self.debug",
"raise AssertionError",
"raise NotImplementedError",
"if __name__ == .__main__.:",
"raise AssertionError",
"raise NotImplementedError",
]

[tool.coverage.paths]
source = [
"fastvector/*",
]

[tool.coverage.html]
directory = "reports"

######## Tools

[tool.black]
line-length = 80
skip-string-normalization = false
skip-magic-trailing-comma = false
exclude = '''
(
asv_bench/env
| \.egg
| \.git
| \.mypy_cache
| \.tox
| \.venv
| build
| setup.py
)
'''

[build-system]
requires = ["setuptools>=45.0", "setuptools_scm[toml]>=6.3.1", "wheel"]
build-backend = "setuptools.build_meta"

[tool.pytest.ini_options]
testpaths = [
"tests"
[tool.isort]
sections = [
"FUTURE",
"STDLIB",
"THIRDPARTY",
"FIRSTPARTY",
"LOCALFOLDER"
]
default_section = "FIRSTPARTY"
known_third_party = [
"numpy",
"pandas",
"keras",
"tensorflow",
"sklearn",
"matplotlib",
"scipy",
"h5py",
"seaborn",
"numba",
"gym",
"PyQt6",
"PyQt5",
"pyqtgraph"
]
multi_line_output = 3
lines_after_imports = 2
force_single_line = true
use_parentheses = true
ensure_newline_before_comments = true
line_length = 80

[tool.mypy]
warn_return_any = true
warn_unused_configs = true
ignore = []
follow_imports = "silent"
check_untyped_defs = true
disallow_incomplete_defs = true
disallow_untyped_defs = true
disallow_subclassing_any = true
strict_optional = true
no_implicit_optional = true
warn_no_return = true
warn_unreachable = true
allow_untyped_globals = false
allow_redefinition = false
local_partial_types = false
implicit_reexport = true
strict_equality = true

[tool.ruff]
select = ["F", "E"]
extend-select = ["W", "I002", "B", "UP", "PLE", "PLW", "NPY", "RUF", "PD", "SIM", "PT"]
unfixable = ["NPY002"]
ignore = []
fixable = ["E", "F", "W", "I", "B", "UP", "PLE", "PLW", "NPY", "RUF", "PD", "SIM", "PT"]
target-version = "py39"

line-length = 80
extend-exclude = ["tests", "test"]
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[tool.ruff.isort]
force-single-line = true
force-sort-within-sections = false
lines-after-imports = 2

[tool.ruff.mccabe]
max-complexity = 10

[tool.ruff.pycodestyle]
ignore-overlong-task-comments = true

[tool.ruff.pydocstyle]
convention = "numpy"

[tool.ruff.flake8-annotations]
allow-star-arg-any = false
ignore-fully-untyped = false
15 changes: 8 additions & 7 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# Runtime requirements
--requirement requirements.txt

build
setuptools>=67.7.1

# Testing
pytest
codecov
pytest-cov
pre-commit

# Linting/Tooling
pylint
flake8
mypy
isort
black
pre-commit
autopep8
black>=23.3.0
isort>=5.12.0
mypy>=1.2.0
pre-commit>=3.2.2
ruff>=0.0.262

# Documentation
mkdocs
Expand Down
Loading

0 comments on commit 7ff0999

Please sign in to comment.