common-python-tasks 0.2.0__py3-none-any.whl → 0.3.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,8 +9,7 @@ __all__ = ["TaskCollection"]
9
9
 
10
10
 
11
11
  def tasks(
12
- include_tags: "Sequence[str] | None" = None,
13
- exclude_tags: "Sequence[str]" = tuple(),
12
+ include_tags: "Sequence[str] | None" = None, exclude_tags: "Sequence[str]" = tuple()
14
13
  ) -> dict:
15
14
  from .tasks import tasks as task_collection
16
15
 
@@ -19,9 +18,4 @@ def tasks(
19
18
  elif include_tags is None:
20
19
  include_tags = tuple()
21
20
 
22
- result = task_collection(include_tags=include_tags, exclude_tags=exclude_tags)
23
- globals()["tasks"] = _TASKS_ENTRYPOINT
24
- return result
25
-
26
-
27
- _TASKS_ENTRYPOINT = tasks
21
+ return task_collection(include_tags=include_tags, exclude_tags=exclude_tags)
@@ -13,7 +13,7 @@ def get_available_tasks(internal: bool = False) -> list[str]:
13
13
  """Return available task names for this package.
14
14
 
15
15
  Args:
16
- internal: When True, include internal task names starting with '_'.
16
+ internal: If `True`, include internal task names starting with '_'.
17
17
 
18
18
  Returns:
19
19
  A list of task names.
@@ -39,7 +39,6 @@ def _extract_docstring_excerpt(doc: str) -> str:
39
39
 
40
40
 
41
41
  def _get_task_docstring(task_name: str) -> str | None:
42
-
43
42
  task_config = tasks()["tasks"].get(task_name)
44
43
  if not isinstance(task_config, dict):
45
44
  return None
@@ -50,11 +49,8 @@ def _get_task_docstring(task_name: str) -> str | None:
50
49
 
51
50
  module_name, func_name = script.split(":", 1)
52
51
 
53
- try:
54
- module = importlib.import_module(module_name)
55
- func = getattr(module, func_name)
56
- except (ImportError, AttributeError):
57
- return None
52
+ module = importlib.import_module(module_name)
53
+ func = getattr(module, func_name)
58
54
 
59
55
  doc = inspect.getdoc(func)
60
56
  if not doc:
@@ -63,17 +59,25 @@ def _get_task_docstring(task_name: str) -> str | None:
63
59
  return _extract_docstring_excerpt(doc)
64
60
 
65
61
 
66
- def _get_task_tags(task_name: str) -> list[str] | None:
67
- task_variants = getattr(tasks, "_tasks", {}).get(task_name)
68
- if not task_variants:
69
- return None
62
+ def get_task_tags(task_name: str) -> list[str] | None:
63
+ """Return the tags associated with a task.
64
+
65
+ Args:
66
+ task_name: The name of the task.
67
+
68
+ Returns:
69
+ A list of tags associated with the task, or `None` if no tags are found.
70
+ """
71
+ tags = set()
72
+ for task in tasks:
73
+ if task.name != task_name:
74
+ continue
75
+
76
+ for tag in task.tags:
77
+ # `task-...` tags are internal synthetic tags auto-added by TaskCollection.
78
+ if not tag.startswith("task-"):
79
+ tags.add(tag)
70
80
 
71
- tags = {
72
- tag
73
- for variant in task_variants
74
- for tag in getattr(variant, "tags", ())
75
- if isinstance(tag, str) and not tag.startswith("task-")
76
- }
77
81
  return sorted(tags) or None
78
82
 
79
83
 
@@ -81,8 +85,8 @@ def print_available_tasks(internal: bool = False, include_docs: bool = False) ->
81
85
  """Print available tasks.
82
86
 
83
87
  Args:
84
- internal: Whether or not to include internal task names starting with '_'.
85
- include_docs: Whether or not to include task docstrings.
88
+ internal: If `True`, include internal task names starting with '_'.
89
+ include_docs: If `True`, include task docstrings.
86
90
  """
87
91
  print("\nAvailable tasks in this release:\n")
88
92
  for task_name in get_available_tasks(internal=internal):
@@ -0,0 +1,5 @@
1
+ [git]
2
+ conventional_commits = true
3
+
4
+ [bump]
5
+ breaking_always_bump_major = false