Skip to content

Commit e07e904

Browse files
authored
Merge pull request #19 from luftfartsverket/13-various-refactoring
BREAKING CHANGE: Refactors reqstool decorators build hook
2 parents a317a35 + 42eaccd commit e07e904

8 files changed

Lines changed: 47 additions & 77 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: Install dependencies
3030
run: pip install hatch
3131
- name: Run unit and integrations tests
32-
run: hatch run test:pytest --cov=reqstool-python-decorators --cov-report=xml --cov-report=html
32+
run: hatch run dev:pytest --cov=reqstool-python-decorators --cov-report=xml --cov-report=html
3333
- name: Build project
3434
run: hatch build
3535
# Upload artifacts for later use

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ jobs:
1616
- name: Install pip package(s)
1717
run: pip install hatch
1818
- name: Run black formatter check
19-
run: hatch run lint:black --check --verbose src tests
19+
run: hatch run dev:black --check --verbose src tests
2020
- name: Run flake8 linter
21-
run: hatch run lint:flake8
21+
run: hatch run dev:flake8

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ When you declare this in the pyproject.toml file, you are specifying the require
3434
The plugin can be configured through the `pyproject.toml` file. Configure plugin in `pyproject.toml`as follows;
3535

3636
```
37-
[tool.hatch.build.targets.wheel.hooks.decorators]
37+
[tool.hatch.build.hooks.reqstool_decorators]
3838
dependencies = ["reqstool-python-hatch-plugin == <version>"]
3939
path = ["src","tests"]
4040

docs/modules/ROOT/pages/usage.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
The plugin can be configured through the `pyproject.toml` file. Configure plugin in `pyproject.toml`as follows;
77

8-
```
9-
[tool.hatch.build.targets.wheel.hooks.decorators]
8+
```toml
9+
[tool.hatch.build.hooks.reqstool_decorators]
1010
dependencies = ["reqstool-python-hatch-plugin == <version>"]
1111
path = ["src","tests"]
1212

pyproject.toml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["hatchling", "hatch-vcs", "build", "twine"]
33
build-backend = "hatchling.build"
44

55
[tool.pytest.ini_options]
6-
addopts = ["-s", "--import-mode=importlib"]
6+
addopts = ["-s", "--import-mode=importlib", "--log-cli-level=DEBUG"]
77
pythonpath = [".", "src", "tests"]
88
testpaths = ["tests/unit"]
99

@@ -38,8 +38,6 @@ dependencies = [
3838

3939
packages = [{ include = "reqstool_python_hatch_plugin", from = "src" }]
4040

41-
[project.scripts]
42-
4341
[project.entry-points.hatch]
4442
decorators = "reqstool_python_hatch_plugin.hooks"
4543

@@ -49,12 +47,15 @@ source = "vcs"
4947
[tool.hatch.version.raw-options]
5048
local_scheme = "no-local-version"
5149

52-
[tool.hatch.envs.test]
53-
dependencies = ["pytest==8.3.3", "pytest-sugar==1.0.0", "pytest-cov==5.0.0"]
54-
55-
[tool.hatch.envs.lint]
56-
detached = true
57-
dependencies = ["black==24.10.0", "flake8==7.1.1", "flake8-pyproject==1.2.3"]
50+
[tool.hatch.envs.dev]
51+
dependencies = [
52+
"black==24.10.0",
53+
"flake8-pyproject==1.2.3",
54+
"flake8==7.1.1",
55+
"pytest-cov==5.0.0",
56+
"pytest-sugar==1.0.0",
57+
"pytest==8.3.3",
58+
]
5859

5960
[tool.black]
6061
line-length = 120

src/reqstool_python_hatch_plugin/build_hook/hook.py

Lines changed: 0 additions & 60 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright © LFV
2+
3+
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
4+
from reqstool_python_decorators.processors.decorator_processor import DecoratorProcessor
5+
6+
7+
class ReqstoolDecorators(BuildHookInterface):
8+
"""
9+
Build hook that creates reqstool annotations files based on reqstool decorators.
10+
Attributes:
11+
PLUGIN_NAME (str): The name of the plugin, set to "reqstool_decorators".
12+
13+
Methods:
14+
initialize(version, build_data):
15+
Executes custom actions during the build process, such as processing decorated Python files.
16+
"""
17+
18+
PLUGIN_NAME = "reqstool_decorators"
19+
20+
def __init__(self, *args, **kwargs):
21+
super().__init__(*args, **kwargs)
22+
self.__config_path = None
23+
24+
def initialize(self, version, build_data):
25+
path = self.config.get("path", [])
26+
27+
decorator_processor = DecoratorProcessor()
28+
decorator_processor.process_decorated_data(path_to_python_files=path)
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Copyright © LFV
22

33
from hatchling.plugin import hookimpl
4-
from reqstool_python_hatch_plugin.build_hook.hook import Decorator
4+
5+
from reqstool_python_hatch_plugin.build_hooks.reqstool_decorators import ReqstoolDecorators
56

67

78
@hookimpl
89
def hatch_register_build_hook():
9-
return Decorator
10+
return ReqstoolDecorators

0 commit comments

Comments
 (0)