core-dev-tools 2.0.0__tar.gz → 2.1.0__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: core-dev-tools
3
- Version: 2.0.0
3
+ Version: 2.1.0
4
4
  Summary: This library provides common tools used for development...
5
5
  Author-email: Alejandro Cora González <alek.cora.glez@gmail.com>
6
6
  Maintainer: Alejandro Cora González
@@ -80,6 +80,10 @@ the ecosystem without any per-project duplication.
80
80
 
81
81
  ===============================================================================
82
82
 
83
+ .. image:: https://static.pepy.tech/personalized-badge/core-dev-tools?period=total&units=INTERNATIONAL_SYSTEM&left_color=BLACK&right_color=GREEN&left_text=downloads
84
+ :target: https://pepy.tech/projects/core-dev-tools
85
+ :alt: PyPI Downloads
86
+
83
87
  .. image:: https://img.shields.io/pypi/pyversions/core-dev-tools.svg
84
88
  :target: https://pypi.org/project/core-dev-tools/
85
89
  :alt: Python Versions
@@ -131,6 +135,37 @@ on the ``PATH``:
131
135
  For detailed documentation, visit: https://core-dev-tools.readthedocs.io/
132
136
 
133
137
 
138
+ Development
139
+ ===============================================================================
140
+
141
+ **Run the test suite:**
142
+
143
+ .. code-block:: bash
144
+
145
+ python -m unittest discover -v tests/unit
146
+
147
+ **Run tests with coverage report:**
148
+
149
+ .. code-block:: bash
150
+
151
+ coverage run -m unittest discover tests/unit
152
+ coverage report -m # Terminal summary
153
+ coverage html # HTML report in htmlcov/
154
+
155
+ **Run linters against the package:**
156
+
157
+ .. code-block:: bash
158
+
159
+ python manager.py run-linters core_dev_tools
160
+ python manager.py run-linters core_dev_tools --tool ruff --tool mypy # Specific tools only
161
+
162
+ **Run security scanners against the package:**
163
+
164
+ .. code-block:: bash
165
+
166
+ python manager.py run-security core_dev_tools
167
+
168
+
134
169
  CI/CD Usage
135
170
  ===============================================================================
136
171
 
@@ -26,6 +26,10 @@ the ecosystem without any per-project duplication.
26
26
 
27
27
  ===============================================================================
28
28
 
29
+ .. image:: https://static.pepy.tech/personalized-badge/core-dev-tools?period=total&units=INTERNATIONAL_SYSTEM&left_color=BLACK&right_color=GREEN&left_text=downloads
30
+ :target: https://pepy.tech/projects/core-dev-tools
31
+ :alt: PyPI Downloads
32
+
29
33
  .. image:: https://img.shields.io/pypi/pyversions/core-dev-tools.svg
30
34
  :target: https://pypi.org/project/core-dev-tools/
31
35
  :alt: Python Versions
@@ -77,6 +81,37 @@ on the ``PATH``:
77
81
  For detailed documentation, visit: https://core-dev-tools.readthedocs.io/
78
82
 
79
83
 
84
+ Development
85
+ ===============================================================================
86
+
87
+ **Run the test suite:**
88
+
89
+ .. code-block:: bash
90
+
91
+ python -m unittest discover -v tests/unit
92
+
93
+ **Run tests with coverage report:**
94
+
95
+ .. code-block:: bash
96
+
97
+ coverage run -m unittest discover tests/unit
98
+ coverage report -m # Terminal summary
99
+ coverage html # HTML report in htmlcov/
100
+
101
+ **Run linters against the package:**
102
+
103
+ .. code-block:: bash
104
+
105
+ python manager.py run-linters core_dev_tools
106
+ python manager.py run-linters core_dev_tools --tool ruff --tool mypy # Specific tools only
107
+
108
+ **Run security scanners against the package:**
109
+
110
+ .. code-block:: bash
111
+
112
+ python manager.py run-security core_dev_tools
113
+
114
+
80
115
  CI/CD Usage
81
116
  ===============================================================================
82
117
 
@@ -0,0 +1,19 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ """
4
+ Provides common tools used for development.
5
+ """
6
+
7
+ from importlib.metadata import PackageNotFoundError
8
+ from importlib.metadata import version
9
+
10
+ try:
11
+ __version__ = version("core-dev-tools")
12
+
13
+ except PackageNotFoundError:
14
+ __version__ = "unknown"
15
+
16
+
17
+ __all__ = [
18
+ "__version__",
19
+ ]
File without changes
@@ -0,0 +1,136 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ """
4
+ This module provides a group of CLI commands that abstract linter, type
5
+ checker, and security tool execution. Consuming projects import ``cli_dev``
6
+ and wire it into their own ``CommandCollection`` to expose ``run-linters`` and
7
+ ``run-security`` without duplicating this logic.
8
+
9
+ **Available Commands:**
10
+
11
+ * ``python manager.py run-linters <package>``
12
+ * ``python manager.py run-linters core_dev_tools --tool ruff``
13
+ * ``python manager.py run-linters core_dev_tools --tool mypy --tool pyright``
14
+ * ``python manager.py run-security <package>``
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ import subprocess # nosec B404
20
+ import sys
21
+ from typing import List, Tuple
22
+
23
+ from click import argument, echo, option
24
+ from click.decorators import group
25
+
26
+ LINTERS: List[Tuple[str, List[str]]] = [
27
+ ("ty", ["ty", "check"]),
28
+ ("ruff", ["ruff", "check"]),
29
+ ("mypy", ["mypy", "--explicit-package-bases"]),
30
+ ("pyright", ["pyright"]),
31
+ ("pylint", ["pylint"]),
32
+ ]
33
+
34
+ _LINTER_NAMES = [name for name, _ in LINTERS]
35
+
36
+ # Third element indicates whether the tool accepts a package path argument.
37
+ SECURITY_TOOLS: List[Tuple[str, List[str], bool]] = [
38
+ ("bandit", ["bandit", "-r"], True),
39
+ ("pip-audit", ["pip-audit"], False),
40
+ ]
41
+
42
+
43
+ @group()
44
+ def cli_dev():
45
+ """
46
+ Group of commands related to linters and type checkers.
47
+ """
48
+
49
+
50
+ @cli_dev.command("run-linters")
51
+ @argument("package")
52
+ @option(
53
+ "-t",
54
+ "--tool",
55
+ "tools",
56
+ multiple=True,
57
+ type=str,
58
+ help="Run only the specified linter(s). Can be repeated. "
59
+ f"Available: {', '.join(_LINTER_NAMES)}. Defaults to all.",
60
+ )
61
+ def run_linters(package: str, tools: Tuple[str, ...]) -> None:
62
+ """
63
+ Runs linters and type checkers against PACKAGE.
64
+
65
+ :param package: Root package directory to check (e.g. ``core_dev_tools``).
66
+ :param tools: Subset of linters to run. When omitted, all linters run.
67
+
68
+ By default, runs all five tools in order:
69
+ - ty check
70
+ - ruff check
71
+ - mypy
72
+ - pyright
73
+ - pylint
74
+
75
+ All linters always run; a non-zero exit from any tool is collected and
76
+ reported at the end, then the command exits with code 1.
77
+ """
78
+
79
+ invalid = set(tools) - set(_LINTER_NAMES)
80
+ if invalid:
81
+ echo(
82
+ f"Unknown linter(s): {', '.join(sorted(invalid))}. "
83
+ f"Available: {', '.join(_LINTER_NAMES)}",
84
+ err=True,
85
+ )
86
+ sys.exit(1)
87
+
88
+ selected = [(name, cmd) for name, cmd in LINTERS if not tools or name in tools]
89
+
90
+ failed: List[str] = []
91
+
92
+ for name, base_cmd in selected:
93
+ echo(f"\n--- {name} ---")
94
+ result = subprocess.run(base_cmd + [package], check=False) # nosec B603
95
+ if result.returncode != 0:
96
+ failed.append(name)
97
+
98
+ echo("")
99
+ if failed:
100
+ echo(f"Linters failed: {', '.join(failed)}", err=True)
101
+ sys.exit(1)
102
+
103
+ echo("All linters passed.")
104
+
105
+
106
+ @cli_dev.command("run-security")
107
+ @argument("package")
108
+ def run_security(package: str) -> None:
109
+ """
110
+ Runs security scanners against PACKAGE.
111
+
112
+ :param package: Root package directory to scan (e.g. ``core_dev_tools``).
113
+
114
+ Runs in order:
115
+ - bandit -r <package>
116
+ - pip-audit
117
+
118
+ All tools always run; a non-zero exit from any tool is collected and
119
+ reported at the end, then the command exits with code 1.
120
+ """
121
+
122
+ failed: List[str] = []
123
+
124
+ for name, base_cmd, takes_path in SECURITY_TOOLS:
125
+ echo(f"\n--- {name} ---")
126
+ cmd = base_cmd + ([package] if takes_path else [])
127
+ result = subprocess.run(cmd, check=False) # nosec B603
128
+ if result.returncode != 0:
129
+ failed.append(name)
130
+
131
+ echo("")
132
+ if failed:
133
+ echo(f"Security tools failed: {', '.join(failed)}", err=True)
134
+ sys.exit(1)
135
+
136
+ echo("All security checks passed.")
File without changes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: core-dev-tools
3
- Version: 2.0.0
3
+ Version: 2.1.0
4
4
  Summary: This library provides common tools used for development...
5
5
  Author-email: Alejandro Cora González <alek.cora.glez@gmail.com>
6
6
  Maintainer: Alejandro Cora González
@@ -80,6 +80,10 @@ the ecosystem without any per-project duplication.
80
80
 
81
81
  ===============================================================================
82
82
 
83
+ .. image:: https://static.pepy.tech/personalized-badge/core-dev-tools?period=total&units=INTERNATIONAL_SYSTEM&left_color=BLACK&right_color=GREEN&left_text=downloads
84
+ :target: https://pepy.tech/projects/core-dev-tools
85
+ :alt: PyPI Downloads
86
+
83
87
  .. image:: https://img.shields.io/pypi/pyversions/core-dev-tools.svg
84
88
  :target: https://pypi.org/project/core-dev-tools/
85
89
  :alt: Python Versions
@@ -131,6 +135,37 @@ on the ``PATH``:
131
135
  For detailed documentation, visit: https://core-dev-tools.readthedocs.io/
132
136
 
133
137
 
138
+ Development
139
+ ===============================================================================
140
+
141
+ **Run the test suite:**
142
+
143
+ .. code-block:: bash
144
+
145
+ python -m unittest discover -v tests/unit
146
+
147
+ **Run tests with coverage report:**
148
+
149
+ .. code-block:: bash
150
+
151
+ coverage run -m unittest discover tests/unit
152
+ coverage report -m # Terminal summary
153
+ coverage html # HTML report in htmlcov/
154
+
155
+ **Run linters against the package:**
156
+
157
+ .. code-block:: bash
158
+
159
+ python manager.py run-linters core_dev_tools
160
+ python manager.py run-linters core_dev_tools --tool ruff --tool mypy # Specific tools only
161
+
162
+ **Run security scanners against the package:**
163
+
164
+ .. code-block:: bash
165
+
166
+ python manager.py run-security core_dev_tools
167
+
168
+
134
169
  CI/CD Usage
135
170
  ===============================================================================
136
171
 
@@ -2,8 +2,12 @@ LICENSE
2
2
  README.rst
3
3
  pyproject.toml
4
4
  setup.py
5
+ core_dev_tools/__init__.py
6
+ core_dev_tools/py.typed
5
7
  core_dev_tools.egg-info/PKG-INFO
6
8
  core_dev_tools.egg-info/SOURCES.txt
7
9
  core_dev_tools.egg-info/dependency_links.txt
8
10
  core_dev_tools.egg-info/requires.txt
9
- core_dev_tools.egg-info/top_level.txt
11
+ core_dev_tools.egg-info/top_level.txt
12
+ core_dev_tools/cli/__init__.py
13
+ core_dev_tools/cli/runner.py
@@ -0,0 +1 @@
1
+ core_dev_tools
@@ -9,7 +9,7 @@ build-backend = "setuptools.build_meta"
9
9
  [project]
10
10
  name = "core-dev-tools"
11
11
  description = "This library provides common tools used for development..."
12
- version = "2.0.0"
12
+ version = "2.1.0"
13
13
 
14
14
  authors = [
15
15
  {name = "Alejandro Cora González", email = "alek.cora.glez@gmail.com"}
File without changes
File without changes
File without changes