Skip to content

Commit

Permalink
Merge pull request #7 from Deric-W/hatch
Browse files Browse the repository at this point in the history
Hatch
  • Loading branch information
Deric-W authored Feb 7, 2024
2 parents 5657586 + d877ea9 commit da21165
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 29 deletions.
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
max-line-length = 100
extend-ignore = E221,E501
39 changes: 19 additions & 20 deletions .github/workflows/Tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,31 @@ on: [push, workflow_dispatch]

jobs:
Test:
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
os: [ubuntu-latest]

runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install test dependencies
run: python -m pip install mypy coverage build

- name: Build wheel
run: python -m build
python-version: |
3.10
3.11
3.12
- name: Install wheel
run: python -m pip install --no-cache-dir dist/lambda_repl-*.whl
- name: Install Hatch
run: python -m pip install hatch

- name: Perform release check
run: hatch run lint:release

- name: Run MyPy
run: python -m mypy -p lambda_repl
- name: Run tests
run: hatch run test:cov --verbose

- name: Run tests and generate report
run: coverage run -m unittest discover --verbose
- name: Generate report
run: hatch env run -e test.py3.12 coverage xml

- name: Upload coverage
uses: codecov/codecov-action@v4
Expand All @@ -43,6 +38,10 @@ jobs:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: Build wheel
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
run: hatch build

- name: Publish package
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ celerybeat.pid
# Environments
.env
.venv
.direnv
env/
venv/
ENV/
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# lambda_repl

[![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch)
![Tests](https://github.com/Deric-W/lambda_repl/actions/workflows/Tests.yaml/badge.svg)
[![codecov](https://codecov.io/gh/Deric-W/lambda_repl/branch/main/graph/badge.svg?token=SU3982mC17)](https://codecov.io/gh/Deric-W/lambda_repl)

Expand Down
57 changes: 50 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,50 @@ Bugtracker = "https://github.com/Deric-W/lambda_repl/issues"
lambda-repl = "lambda_repl.main:main_cli"

[build-system]
requires = ["setuptools >= 61.0.0"]
build-backend = "setuptools.build_meta"
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.setuptools.package-data]
lambda_repl = [
"py.typed",
"grammar.lark"
[tool.hatch.envs.test]
dependencies = [
"coverage[toml] == 7.*"
]

[tool.hatch.envs.test.scripts]
test = "python -m unittest discover {args}"
cov-run = "coverage run -m unittest discover {args}"
cov-report = [
"- coverage combine",
"coverage report"
]
cov = [
"cov-run",
"cov-report"
]

[[tool.hatch.envs.test.matrix]]
python = ["3.10", "3.11", "3.12"]

[tool.hatch.envs.lint]
dependencies = [
"mypy >= 1.0.0",
"pylint >= 2.12.2",
"flake8 >= 5.0.0",
"isort >= 5.10.1"
]

[tool.hatch.envs.lint.scripts]
lint = [
"- flake8 src/lambda_repl",
"- pylint src/lambda_repl"
]
typecheck = "mypy -p lambda_repl"
release = [
"typecheck"
]

[tool.hatch.build.targets.sdist]
exclude = ["/.github"]

[tool.mypy]
disallow_any_unimported = true
disallow_any_generics = true
Expand All @@ -52,4 +87,12 @@ strict_optional = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_return_any = true
warn_unreachable = true
warn_unreachable = true

[tool.pylint]
max-line-length = 100

[tool.coverage.run]
source_pkgs = ["lambda_repl"]
branch = true
parallel = true
2 changes: 1 addition & 1 deletion lambda_repl/__init__.py → src/lambda_repl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def import_term(self, location: str) -> Term[str] | None:
module, _, name = location.strip().rpartition(".")
try:
term = getattr(import_module(module), name)
except Exception as error:
except Exception as error: # pylint: disable=W0718
self.stdout.write(f"Error while importing: {error}\n")
return None
if not isinstance(term, Term):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion lambda_repl/parsing.py → src/lambda_repl/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def transform_string(self, string: str) -> Term[str]:
case Token(type="VARIABLE") as name: # type: ignore
return self.VARIABLE(name) # type: ignore
case Token() as token: # type: ignore
raise UnexpectedToken(token, {"VARIABLE",})
raise UnexpectedToken(token, {"VARIABLE", })
case tree:
return self.transform(tree)

Expand Down
File renamed without changes.

0 comments on commit da21165

Please sign in to comment.