Skip to content

Commit 1e4caca

Browse files
committed
ci: use hatch
1 parent efe2f51 commit 1e4caca

17 files changed

+107
-713
lines changed

.github/workflows/ci.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
13+
python-version: ['3.8', '3.10', '3.11', '3.12']
1414
steps:
1515
- uses: actions/checkout@v3
1616
- uses: actions/setup-python@v4
1717
with:
1818
python-version: ${{matrix.python-version}}
1919
architecture: x64
2020
allow-prereleases: true
21-
- run: pip install nox==2023.4.22 nox-poetry poetry
22-
- run: nox --session mypy-${{matrix.python-version}}
21+
- run: pip install hatch
22+
- run: hatch run +py=${{matrix.python-version}} types:check
2323

2424
test:
2525
runs-on: ubuntu-latest
@@ -33,5 +33,5 @@ jobs:
3333
python-version: ${{matrix.python-version}}
3434
architecture: x64
3535
allow-prereleases: true
36-
- run: pip install nox==2023.4.22 nox-poetry poetry
37-
- run: nox --sessions test-${{matrix.python-version}}
36+
- run: pip install hatch
37+
- run: hatch test -py ${{matrix.python-version}}

LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2022 Frank Hoffmann
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
THE SOFTWARE.

noxfile.py

-70
This file was deleted.

poetry.lock

-596
This file was deleted.

pyproject.toml

+70-36
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,88 @@
1-
[tool.poetry]
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
26
name = "pysource-codegen"
3-
version = "0.5.2"
4-
description = ""
5-
authors = ["Your Name <[email protected]>"]
7+
version= "0.5.2"
8+
description = 'generate random python code to test linter/formatter/and other tools'
69
readme = "README.md"
7-
packages = [{include = "pysource_codegen"}]
8-
9-
[tool.commitizen]
10-
changelog_incremental = true
11-
major_version_zero = true
12-
tag_format = "v$major.$minor.$patch$prerelease"
13-
update_changelog_on_bump = true
14-
version_files = [
15-
"pysource_codegen/__init__.py:version"
10+
requires-python = ">=3.8"
11+
license = "MIT"
12+
keywords = []
13+
authors = [
14+
{ name = "Frank Hoffmann", email = "[email protected]" },
15+
]
16+
classifiers = [
17+
"Development Status :: 4 - Beta",
18+
"Programming Language :: Python",
19+
"Programming Language :: Python :: 3.8",
20+
"Programming Language :: Python :: 3.9",
21+
"Programming Language :: Python :: 3.10",
22+
"Programming Language :: Python :: 3.11",
23+
"Programming Language :: Python :: 3.12",
24+
"Programming Language :: Python :: Implementation :: CPython",
25+
"Programming Language :: Python :: Implementation :: PyPy",
26+
]
27+
dependencies = [
28+
"astunparse >=1.6.3; python_version<'3.9' ",
29+
"typing-extensions>=4.7.1"
1630
]
17-
version_provider = "poetry"
1831

19-
[tool.poetry.scripts]
20-
pysource-codegen = "pysource_codegen.__main__:run"
32+
[project.urls]
33+
Documentation = "https://github.com/15r10nk/pysource-codegen#readme"
34+
Issues = "https://github.com/15r10nk/pysource-codegen/issues"
35+
Source = "https://github.com/15r10nk/pysource-codegen"
2136

37+
[tool.hatch.version]
38+
path = "src/pysource_codegen/__init__.py"
2239

40+
[tool.hatch.envs.hatch-test]
41+
extra-dependencies=[
42+
"rich>=12.0.0",
43+
"inline-snapshot>=0.4.0",
44+
"pysource-minimize>=0.5.0"
45+
]
2346

47+
[[tool.hatch.envs.types.matrix]]
48+
python=["3.8","3.9","3.10","3.11","3.12"]
2449

25-
[tool.poetry.dependencies]
26-
python = ">=3.8"
27-
astunparse = { version = ">=1.6.3", python ="<3.9"}
28-
#typed-ast = ">=1.5.5"
29-
typing-extensions = ">=4.7.1"
50+
[tool.hatch.envs.types]
51+
extra-dependencies = [
52+
"mypy>=1.0.0",
53+
"rich>=12.0.0",
54+
"inline-snapshot>=0.4.0",
55+
"pysource-minimize>=0.5.0",
56+
"pytest"
57+
]
3058

31-
[tool.poetry.group.dev.dependencies]
32-
rich = ">=12.0.0"
33-
pytest-xdist = {extras = ["psutil"], version = ">=3.2.1"}
34-
pytest = ">=7.2.1"
35-
mypy = ">=1.2.0"
36-
coverage-enable-subprocess = ">=1.0"
37-
inline-snapshot = ">=0.4.0"
38-
pysource-minimize = ">=0.5.0"
39-
40-
[build-system]
41-
requires = ["poetry-core"]
42-
build-backend = "poetry.core.masonry.api"
59+
[tool.hatch.envs.types.scripts]
60+
check = "mypy --install-types --non-interactive {args:src/pysource_codegen tests}"
4361

4462
[tool.coverage.run]
45-
source = ["tests","pysource_codegen"]
46-
parallel = true
63+
source_pkgs = ["pysource_codegen", "tests"]
4764
branch = true
48-
data_file = "$TOP/.coverage"
65+
parallel = true
66+
omit = [
67+
"src/pysource_codegen/__about__.py",
68+
]
69+
70+
[tool.coverage.paths]
71+
pysource_codegen = ["src/pysource_codegen", "*/pysource-codegen/src/pysource_codegen"]
72+
tests = ["tests", "*/pysource-codegen/tests"]
4973

5074
[tool.coverage.report]
5175
exclude_lines = ["assert False", "raise NotImplemented"]
5276

77+
[tool.commitizen]
78+
changelog_incremental = true
79+
major_version_zero = true
80+
tag_format = "v$major.$minor.$patch$prerelease"
81+
update_changelog_on_bump = true
82+
version_files = [
83+
"src/pysource_codegen/__init__.py:__version__"
84+
]
85+
version_provider = "pep621"
86+
5387
[tool.mypy]
5488
exclude="tests/.*_samples"

src/pysource_codegen/__about__.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# SPDX-FileCopyrightText: 2024-present Frank Hoffmann <[email protected]>
2+
#
3+
# SPDX-License-Identifier: MIT
4+
__version__ = "0.5.2"
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
from ._codegen import generate
22

33
__all__ = ("generate",)
4+
5+
__version__ = "0.5.2"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/test_fix_nonlocal.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import sys
33

44
from inline_snapshot import snapshot
5-
65
from pysource_codegen._codegen import fix_nonlocal
76
from pysource_codegen._codegen import unparse
87
from pysource_codegen._utils import ast_dump

tests/test_invalid_ast.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
from pathlib import Path
77

88
import pytest
9-
from pysource_minimize._minimize import minimize_ast
10-
119
from pysource_codegen._codegen import generate_ast
1210
from pysource_codegen._codegen import is_valid_ast
1311
from pysource_codegen._codegen import unparse
1412
from pysource_codegen._utils import ast_dump
13+
from pysource_minimize._minimize import minimize_ast
1514

1615
sample_dir = Path(__file__).parent / "invalid_ast_samples"
1716
sample_dir.mkdir(exist_ok=True)

tests/test_valid_source.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
from unittest.mock import patch
55

66
import pytest
7-
from pysource_minimize import minimize
8-
9-
from .test_invalid_ast import does_compile
107
from pysource_codegen._codegen import generate_ast
118
from pysource_codegen._codegen import is_valid_ast
129
from pysource_codegen._codegen import unparse
10+
from pysource_minimize import minimize
11+
12+
from .test_invalid_ast import does_compile
1313

1414
sample_dir = Path(__file__).parent / "valid_source_samples"
1515
sample_dir.mkdir(exist_ok=True)

0 commit comments

Comments
 (0)