Skip to content

Commit 0205b52

Browse files
authored
Merge pull request #41 from olirice/or/pyproject
Modernize
2 parents b787d60 + 2eb8d7a commit 0205b52

File tree

9 files changed

+133
-143
lines changed

9 files changed

+133
-143
lines changed

.github/workflows/pre-commit_hooks.yaml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,25 @@ jobs:
77
runs-on: ubuntu-latest
88

99
steps:
10-
- name: checkout
11-
uses: actions/checkout@v2
1210

13-
- name: set up python 3.8
11+
- uses: actions/checkout@v1
12+
13+
- name: python setup 3.9
1414
uses: actions/setup-python@v1
1515
with:
16-
python-version: 3.8
16+
python-version: '3.9'
17+
18+
- name: Install Poetry
19+
uses: snok/install-poetry@v1
20+
with:
21+
version: 1.7.1
22+
virtualenvs-create: true
23+
virtualenvs-in-project: true
1724

18-
- name: install pre-commit
25+
- name: Install dependencies
1926
run: |
20-
python -m pip install --upgrade pip
21-
pip install pre-commit
27+
poetry install --with dev
2228
23-
- name: run static analysis
29+
- name: run tests
2430
run: |
25-
pre-commit run --all-files
31+
poetry run pre-commit run --all

.github/workflows/test.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88

99
strategy:
1010
matrix:
11-
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
11+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
1212

1313
steps:
1414

@@ -19,14 +19,20 @@ jobs:
1919
with:
2020
python-version: ${{ matrix.python-version }}
2121

22-
- name: install flupy
22+
- name: Install Poetry
23+
uses: snok/install-poetry@v1
24+
with:
25+
version: 1.7.1
26+
virtualenvs-create: true
27+
virtualenvs-in-project: true
28+
29+
- name: Install dependencies
2330
run: |
24-
python -m pip install --upgrade pip
25-
pip install -e ".[dev]"
31+
poetry install --with dev
2632
2733
- name: run tests
2834
run: |
29-
pytest --cov=src/flupy src/tests --cov-report=xml
35+
poetry run pytest --cov=src/flupy src/tests --cov-report=xml
3036
3137
- name: upload coverage to codecov
3238
uses: codecov/codecov-action@v1

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ __pycache__
99
.python-version
1010

1111
.benchmarks
12+
poetry.lock
1213

1314
pip-wheel-metadata/
1415

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
repos:
22
- repo: https://github.com/pre-commit/mirrors-isort
3-
rev: v5.6.4
3+
rev: v5.10.1
44
hooks:
55
- id: isort
66
args: ['--multi-line=3', '--trailing-comma', '--force-grid-wrap=0', '--use-parentheses', '--line-width=88']
77

88

99
- repo: https://github.com/pre-commit/pre-commit-hooks
10-
rev: v3.3.0
10+
rev: v5.0.0
1111
hooks:
1212
- id: trailing-whitespace
1313
- id: check-added-large-files
@@ -21,14 +21,14 @@ repos:
2121
- id: autoflake
2222
args: ['--in-place', '--remove-all-unused-imports']
2323

24-
- repo: https://github.com/ambv/black
25-
rev: 22.10.0
24+
- repo: https://github.com/psf/black
25+
rev: 25.1.0
2626
hooks:
2727
- id: black
28-
language_version: python3.8
28+
language_version: python3.9
2929

3030
- repo: https://github.com/pre-commit/mirrors-mypy
31-
rev: v1.11.2
31+
rev: v1.15.0
3232
hooks:
3333
- id: mypy
3434
files: flupy/

pyproject.toml

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,48 @@
1+
[tool.poetry]
2+
name = "flupy"
3+
version = "1.2.2"
4+
description = "Fluent data processing in Python - a chainable stream processing library for expressive data manipulation using method chaining"
5+
authors = ["Oliver Rice <oliver@oliverrice.com>"]
6+
license = "MIT"
7+
readme = "README.md"
8+
repository = "https://github.com/olirice/flupy"
9+
packages = [{include = "flupy", from = "src"}]
10+
classifiers = [
11+
"Development Status :: 4 - Beta",
12+
"Natural Language :: English",
13+
"Operating System :: OS Independent",
14+
"Programming Language :: Python",
15+
"Programming Language :: Python :: 3",
16+
"Programming Language :: Python :: 3.9",
17+
"Programming Language :: Python :: 3.10",
18+
"Programming Language :: Python :: 3.11",
19+
"Programming Language :: Python :: 3.12",
20+
"Programming Language :: Python :: 3.13",
21+
]
22+
23+
[tool.poetry.dependencies]
24+
python = ">=3.9"
25+
typing_extensions = ">=4"
26+
27+
[tool.poetry.group.dev.dependencies]
28+
pytest = "*"
29+
pytest-cov = "*"
30+
pytest-benchmark = "*"
31+
pre-commit = "*"
32+
pylint = "*"
33+
black = "*"
34+
mypy = "*"
35+
36+
[tool.poetry.scripts]
37+
flu = "flupy.cli.cli:main"
38+
flu_precommit = "flupy.cli.cli:precommit"
39+
40+
[build-system]
41+
requires = ["poetry-core>=2.0.0"]
42+
build-backend = "poetry.core.masonry.api"
43+
144
[tool.black]
2-
line-length=120
45+
line-length = 120
346
exclude = '''
447
/(
548
\.git
@@ -13,3 +56,28 @@ exclude = '''
1356
| dist
1457
)/
1558
'''
59+
60+
[tool.mypy]
61+
python_version = "3.9"
62+
ignore_missing_imports = true
63+
strict_optional = true
64+
follow_imports = "skip"
65+
warn_redundant_casts = true
66+
warn_unused_ignores = false
67+
check_untyped_defs = true
68+
no_implicit_reexport = true
69+
disallow_untyped_defs = true
70+
disallow_any_generics = true
71+
72+
[tool.pytest.ini_options]
73+
addopts = "--cov=src/flupy src/tests"
74+
75+
[tool.coverage.report]
76+
exclude_lines = [
77+
"pragma: no cover",
78+
"if TYPE_CHECKING:",
79+
"raise AssertionError",
80+
"raise NotImplementedError",
81+
"@overload",
82+
"pass",
83+
]

setup.py

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

src/flupy/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
from importlib.metadata import version
2+
13
from flupy.cli.utils import walk_dirs, walk_files
24
from flupy.fluent import flu
35

46
__project__ = "flupy"
5-
6-
__version__ = "1.2.1"
7+
__version__ = version(__project__)
78

89
__all__ = ["flu", "walk_files", "walk_dirs"]

src/flupy/fluent.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -510,18 +510,15 @@ def fold_left(self, func: Callable[[S, T], S], initial: S) -> S:
510510
return reduce(func, self, initial)
511511

512512
@overload
513-
def zip(self, __iter1: Iterable[_T1]) -> "Fluent[Tuple[T, _T1]]":
514-
...
513+
def zip(self, __iter1: Iterable[_T1]) -> "Fluent[Tuple[T, _T1]]": ...
515514

516515
@overload
517-
def zip(self, __iter1: Iterable[_T1], __iter2: Iterable[_T2]) -> "Fluent[Tuple[T, _T1, _T2]]":
518-
...
516+
def zip(self, __iter1: Iterable[_T1], __iter2: Iterable[_T2]) -> "Fluent[Tuple[T, _T1, _T2]]": ...
519517

520518
@overload
521519
def zip(
522520
self, __iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3]
523-
) -> "Fluent[Tuple[T, _T1, _T2, _T3]]":
524-
...
521+
) -> "Fluent[Tuple[T, _T1, _T2, _T3]]": ...
525522

526523
@overload
527524
def zip(
@@ -531,12 +528,9 @@ def zip(
531528
__iter3: Iterable[Any],
532529
__iter4: Iterable[Any],
533530
*iterable: Iterable[Any],
534-
) -> "Fluent[Tuple[T, ...]]":
535-
...
531+
) -> "Fluent[Tuple[T, ...]]": ...
536532

537-
def zip(
538-
self, *iterable: Iterable[Any]
539-
) -> Union[
533+
def zip(self, *iterable: Iterable[Any]) -> Union[
540534
"Fluent[Tuple[T, ...]]",
541535
"Fluent[Tuple[T, _T1]]",
542536
"Fluent[Tuple[T, _T1, _T2]]",

src/tests/test_version.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
Tests for version information.
3+
"""
4+
5+
import re
6+
7+
import flupy
8+
9+
10+
def test_version_format():
11+
"""Test that __version__ follows semantic versioning format (MAJOR.MINOR.PATCH)."""
12+
# Standard semver regex pattern
13+
semver_pattern = r"^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
14+
15+
assert re.match(
16+
semver_pattern, flupy.__version__
17+
), f"Version '{flupy.__version__}' does not match semantic versioning format"
18+
19+
# Ensure version parts can be parsed as integers
20+
major, minor, patch = flupy.__version__.split("-")[0].split("+")[0].split(".")[:3]
21+
assert major.isdigit(), f"Major version '{major}' is not a valid integer"
22+
assert minor.isdigit(), f"Minor version '{minor}' is not a valid integer"
23+
assert patch.isdigit(), f"Patch version '{patch}' is not a valid integer"

0 commit comments

Comments
 (0)