Skip to content

Commit

Permalink
ci: use hatch
Browse files Browse the repository at this point in the history
  • Loading branch information
15r10nk committed Jul 16, 2024
1 parent efe2f51 commit 0f0f1d5
Show file tree
Hide file tree
Showing 17 changed files with 107 additions and 713 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.8', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{matrix.python-version}}
architecture: x64
allow-prereleases: true
- run: pip install nox==2023.4.22 nox-poetry poetry
- run: nox --session mypy-${{matrix.python-version}}
- run: pip install hatch
- run: hatch run +py=${{matrix.python-version}} types:check

test:
runs-on: ubuntu-latest
Expand All @@ -33,5 +33,5 @@ jobs:
python-version: ${{matrix.python-version}}
architecture: x64
allow-prereleases: true
- run: pip install nox==2023.4.22 nox-poetry poetry
- run: nox --sessions test-${{matrix.python-version}}
- run: pip install hatch
- run: hatch test -py ${{matrix.python-version}}
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

The MIT License (MIT)

Copyright (c) 2022 Frank Hoffmann

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
70 changes: 0 additions & 70 deletions noxfile.py

This file was deleted.

596 changes: 0 additions & 596 deletions poetry.lock

This file was deleted.

106 changes: 70 additions & 36 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,54 +1,88 @@
[tool.poetry]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "pysource-codegen"
version = "0.5.2"
description = ""
authors = ["Your Name <[email protected]>"]
version= "0.5.2"
description = 'generate random python source code'
readme = "README.md"
packages = [{include = "pysource_codegen"}]

[tool.commitizen]
changelog_incremental = true
major_version_zero = true
tag_format = "v$major.$minor.$patch$prerelease"
update_changelog_on_bump = true
version_files = [
"pysource_codegen/__init__.py:version"
requires-python = ">=3.8"
license = "MIT"
keywords = []
authors = [
{ name = "Frank Hoffmann", email = "[email protected]" },
]
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
dependencies = [
"astunparse >=1.6.3; python_version<'3.9' ",
"typing-extensions>=4.7.1"
]
version_provider = "poetry"

[tool.poetry.scripts]
pysource-codegen = "pysource_codegen.__main__:run"
[project.urls]
Documentation = "https://github.com/15r10nk/pysource-codegen#readme"
Issues = "https://github.com/15r10nk/pysource-codegen/issues"
Source = "https://github.com/15r10nk/pysource-codegen"

[tool.hatch.version]
path = "src/pysource_codegen/__init__.py"

[tool.hatch.envs.hatch-test]
extra-dependencies=[
"rich>=12.0.0",
"inline-snapshot>=0.4.0",
"pysource-minimize>=0.5.0"
]

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

[tool.poetry.dependencies]
python = ">=3.8"
astunparse = { version = ">=1.6.3", python ="<3.9"}
#typed-ast = ">=1.5.5"
typing-extensions = ">=4.7.1"
[tool.hatch.envs.types]
extra-dependencies = [
"mypy>=1.0.0",
"rich>=12.0.0",
"inline-snapshot>=0.4.0",
"pysource-minimize>=0.5.0",
"pytest"
]

[tool.poetry.group.dev.dependencies]
rich = ">=12.0.0"
pytest-xdist = {extras = ["psutil"], version = ">=3.2.1"}
pytest = ">=7.2.1"
mypy = ">=1.2.0"
coverage-enable-subprocess = ">=1.0"
inline-snapshot = ">=0.4.0"
pysource-minimize = ">=0.5.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
[tool.hatch.envs.types.scripts]
check = "mypy --install-types --non-interactive {args:src/pysource_codegen tests}"

[tool.coverage.run]
source = ["tests","pysource_codegen"]
parallel = true
source_pkgs = ["pysource_codegen", "tests"]
branch = true
data_file = "$TOP/.coverage"
parallel = true
omit = [
"src/pysource_codegen/__about__.py",
]

[tool.coverage.paths]
pysource_codegen = ["src/pysource_codegen", "*/pysource-codegen/src/pysource_codegen"]
tests = ["tests", "*/pysource-codegen/tests"]

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

[tool.commitizen]
changelog_incremental = true
major_version_zero = true
tag_format = "v$major.$minor.$patch$prerelease"
update_changelog_on_bump = true
version_files = [
"src/pysource_codegen/__init__.py:__version__"
]
version_provider = "pep621"

[tool.mypy]
exclude="tests/.*_samples"
4 changes: 4 additions & 0 deletions src/pysource_codegen/__about__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# SPDX-FileCopyrightText: 2024-present Frank Hoffmann <[email protected]>
#
# SPDX-License-Identifier: MIT
__version__ = "0.5.2"
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from ._codegen import generate

__all__ = ("generate",)

__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.
1 change: 0 additions & 1 deletion tests/test_fix_nonlocal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import sys

from inline_snapshot import snapshot

from pysource_codegen._codegen import fix_nonlocal
from pysource_codegen._codegen import unparse
from pysource_codegen._utils import ast_dump
Expand Down
3 changes: 1 addition & 2 deletions tests/test_invalid_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
from pathlib import Path

import pytest
from pysource_minimize._minimize import minimize_ast

from pysource_codegen._codegen import generate_ast
from pysource_codegen._codegen import is_valid_ast
from pysource_codegen._codegen import unparse
from pysource_codegen._utils import ast_dump
from pysource_minimize._minimize import minimize_ast

sample_dir = Path(__file__).parent / "invalid_ast_samples"
sample_dir.mkdir(exist_ok=True)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_valid_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
from unittest.mock import patch

import pytest
from pysource_minimize import minimize

from .test_invalid_ast import does_compile
from pysource_codegen._codegen import generate_ast
from pysource_codegen._codegen import is_valid_ast
from pysource_codegen._codegen import unparse
from pysource_minimize import minimize

from .test_invalid_ast import does_compile

sample_dir = Path(__file__).parent / "valid_source_samples"
sample_dir.mkdir(exist_ok=True)
Expand Down

0 comments on commit 0f0f1d5

Please sign in to comment.