Skip to content

Commit 5de64e3

Browse files
authored
Refactor pytask to two packages, pytask and _pytask. (#14)
1 parent d7a03aa commit 5de64e3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+216
-195
lines changed

.github/workflows/continuous-integration-workflow.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535

3636
- name: Run unit tests and doctests.
3737
shell: bash -l {0}
38-
run: tox -e pytest -- -m "unit or (not integration and not end_to_end)" --cov=./ --cov-report=xml -n auto
38+
run: tox -e pytest -- -m "unit or (not integration and not end_to_end)" --cov=./src --cov-report=xml -n auto
3939

4040
- name: Upload coverage report for unit tests and doctests.
4141
if: runner.os == 'Linux' && matrix.python-version == '3.8'
@@ -44,7 +44,7 @@ jobs:
4444

4545
- name: Run integration tests.
4646
shell: bash -l {0}
47-
run: tox -e pytest -- -m integration --cov=./ --cov-report=xml -n auto
47+
run: tox -e pytest -- -m integration --cov=./src --cov-report=xml -n auto
4848

4949
- name: Upload coverage reports of integration tests.
5050
if: runner.os == 'Linux' && matrix.python-version == '3.8'
@@ -53,7 +53,7 @@ jobs:
5353

5454
- name: Run end-to-end tests.
5555
shell: bash -l {0}
56-
run: tox -e pytest -- -m end_to_end --cov=./ --cov-report=xml -n auto
56+
run: tox -e pytest -- -m end_to_end --cov=./src --cov-report=xml -n auto
5757

5858
- name: Upload coverage reports of end-to-end tests.
5959
if: runner.os == 'Linux' && matrix.python-version == '3.8'

codecov.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ coverage:
2222
ignore:
2323
- ".tox/**/*"
2424
- "setup.py"
25+
- "tests/**/*"

setup.cfg

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[bumpversion]
22
current_version = 0.0.4
33
parse = (?P<major>\d+)\.(?P<minor>\d+)(\.(?P<patch>\d+))(\-?((dev)?(?P<dev>\d+))?)
4-
serialize =
4+
serialize =
55
{major}.{minor}.{patch}dev{dev}
66
{major}.{minor}.{patch}
77

@@ -10,3 +10,5 @@ serialize =
1010
[bumpversion:file:docs/conf.py]
1111

1212
[bumpversion:file:src/pytask/__init__.py]
13+
14+
[bumpversion:file:src/_pytask/__init__.py]

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"Programming Language :: Python :: 3.8",
3737
],
3838
platforms="any",
39-
entry_points={"console_scripts": ["pytask=pytask.cli:pytask"]},
39+
entry_points={"console_scripts": ["pytask=pytask:pytask"]},
4040
packages=find_packages(where="src"),
4141
package_dir={"": "src"},
4242
)

src/_pytask/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "0.0.4"

src/pytask/cli.py renamed to src/_pytask/cli.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from pathlib import Path
33

44
import click
5-
from pytask.config import hookimpl
6-
from pytask.pluginmanager import get_plugin_manager
5+
from _pytask.config import hookimpl
6+
from _pytask.pluginmanager import get_plugin_manager
77

88

99
CONTEXT_SETTINGS = {"help_option_names": ["-h", "--help"]}
@@ -28,17 +28,17 @@ def _prepare_plugin_manager():
2828

2929
@hookimpl
3030
def pytask_add_hooks(pm):
31-
from pytask import collect
32-
from pytask import config
33-
from pytask import database
34-
from pytask import debugging
35-
from pytask import execute
36-
from pytask import logging
37-
from pytask import main
38-
from pytask import parametrize
39-
from pytask import resolve_dependencies
40-
from pytask import skipping
41-
from pytask import mark_
31+
from _pytask import collect
32+
from _pytask import config
33+
from _pytask import database
34+
from _pytask import debugging
35+
from _pytask import execute
36+
from _pytask import logging
37+
from _pytask import main
38+
from _pytask import parametrize
39+
from _pytask import resolve_dependencies
40+
from _pytask import skipping
41+
from _pytask import mark
4242

4343
pm.register(collect)
4444
pm.register(config)
@@ -50,7 +50,7 @@ def pytask_add_hooks(pm):
5050
pm.register(parametrize)
5151
pm.register(resolve_dependencies)
5252
pm.register(skipping)
53-
pm.register(mark_)
53+
pm.register(mark)
5454

5555

5656
def _to_path(ctx, param, value): # noqa: U100

src/pytask/collect.py renamed to src/_pytask/collect.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88
from pathlib import Path
99

1010
import click
11-
import pytask
12-
from pytask.exceptions import CollectionError
13-
from pytask.exceptions import TaskDuplicatedError
14-
from pytask.mark_ import has_marker
15-
from pytask.nodes import FilePathNode
16-
from pytask.nodes import PythonFunctionTask
17-
from pytask.report import CollectionReport
18-
from pytask.report import CollectionReportFile
19-
from pytask.report import CollectionReportTask
20-
21-
22-
@pytask.hookimpl
11+
from _pytask.config import hookimpl
12+
from _pytask.exceptions import CollectionError
13+
from _pytask.exceptions import TaskDuplicatedError
14+
from _pytask.mark import has_marker
15+
from _pytask.nodes import FilePathNode
16+
from _pytask.nodes import PythonFunctionTask
17+
from _pytask.report import CollectionReport
18+
from _pytask.report import CollectionReportFile
19+
from _pytask.report import CollectionReportTask
20+
21+
22+
@hookimpl
2323
def pytask_collect(session):
2424
reports = _collect_from_paths(session)
2525
tasks = _extract_tasks_from_reports(reports)
@@ -66,13 +66,13 @@ def _collect_from_paths(session):
6666
return collected_reports
6767

6868

69-
@pytask.hookimpl
69+
@hookimpl
7070
def pytask_ignore_collect(path, config):
7171
ignored = any(fnmatch.fnmatch(path, pattern) for pattern in config["ignore"])
7272
return ignored
7373

7474

75-
@pytask.hookimpl
75+
@hookimpl
7676
def pytask_collect_file_protocol(session, path, reports):
7777
try:
7878
reports = session.hook.pytask_collect_file(
@@ -85,7 +85,7 @@ def pytask_collect_file_protocol(session, path, reports):
8585
return reports
8686

8787

88-
@pytask.hookimpl
88+
@hookimpl
8989
def pytask_collect_file(session, path, reports):
9090
if path.name.startswith("task_") and path.suffix == ".py":
9191
spec = importlib.util.spec_from_file_location(path.stem, str(path))
@@ -115,7 +115,7 @@ def pytask_collect_file(session, path, reports):
115115
return collected_reports
116116

117117

118-
@pytask.hookimpl
118+
@hookimpl
119119
def pytask_collect_task_protocol(session, reports, path, name, obj):
120120
try:
121121
session.hook.pytask_collect_task_setup(
@@ -132,7 +132,7 @@ def pytask_collect_task_protocol(session, reports, path, name, obj):
132132
return CollectionReportTask.from_exception(path, name, exc_info)
133133

134134

135-
@pytask.hookimpl(trylast=True)
135+
@hookimpl(trylast=True)
136136
def pytask_collect_task_setup(session, reports, path, name):
137137
paths_to_tasks_w_ident_name = [
138138
i.path.as_posix()
@@ -148,7 +148,7 @@ def pytask_collect_task_setup(session, reports, path, name):
148148
)
149149

150150

151-
@pytask.hookimpl(trylast=True)
151+
@hookimpl(trylast=True)
152152
def pytask_collect_task(session, path, name, obj):
153153
"""Collect a task which is a function.
154154
@@ -163,7 +163,7 @@ def pytask_collect_task(session, path, name, obj):
163163
)
164164

165165

166-
@pytask.hookimpl(trylast=True)
166+
@hookimpl(trylast=True)
167167
def pytask_collect_node(path, node):
168168
"""Collect a node of a task as a :class:`pytask.nodes.FilePathNode`.
169169
@@ -219,7 +219,7 @@ def _extract_tasks_from_reports(reports):
219219
return [i.task for i in reports if i.successful]
220220

221221

222-
@pytask.hookimpl
222+
@hookimpl
223223
def pytask_collect_log(session, reports, tasks):
224224
tm_width = session.config["terminal_width"]
225225

src/pytask/config.py renamed to src/_pytask/config.py

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

99
import click
1010
import pluggy
11-
from pytask.shared import get_first_not_none_value
12-
from pytask.shared import to_list
11+
from _pytask.shared import get_first_not_none_value
12+
from _pytask.shared import to_list
1313

1414

1515
hookimpl = pluggy.HookimplMarker("pytask")
File renamed without changes.

src/pytask/database.py renamed to src/_pytask/database.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from pathlib import Path
22

33
import click
4-
import pytask
4+
from _pytask.config import hookimpl
5+
from _pytask.shared import get_first_not_none_value
56
from pony import orm
6-
from pytask.shared import get_first_not_none_value
77

88

99
db = orm.Database()
@@ -35,7 +35,7 @@ def create_or_update_state(first_key, second_key, state):
3535
state_in_db.state = state
3636

3737

38-
@pytask.hookimpl
38+
@hookimpl
3939
def pytask_add_parameters_to_cli(command):
4040
additional_parameters = [
4141
click.Option(
@@ -60,7 +60,7 @@ def pytask_add_parameters_to_cli(command):
6060
command.params.extend(additional_parameters)
6161

6262

63-
@pytask.hookimpl
63+
@hookimpl
6464
def pytask_parse_config(config, config_from_cli, config_from_file):
6565
provider = get_first_not_none_value(
6666
config_from_cli, config_from_file, key="database_provider", default="sqlite"

0 commit comments

Comments
 (0)