core-dev-tools 2.0.0__tar.gz → 2.1.1__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.1
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,16 @@
1
+ """
2
+ Provides common tools used for development.
3
+ """
4
+
5
+ from importlib.metadata import PackageNotFoundError, version
6
+
7
+ try:
8
+ __version__ = version("core-dev-tools")
9
+
10
+ except PackageNotFoundError:
11
+ __version__ = "unknown"
12
+
13
+
14
+ __all__ = [
15
+ "__version__",
16
+ ]
File without changes
@@ -0,0 +1,133 @@
1
+ """
2
+ This module provides a group of CLI commands that abstract linter, type
3
+ checker, and security tool execution. Consuming projects import ``cli_dev``
4
+ and wire it into their own ``CommandCollection`` to expose ``run-linters`` and
5
+ ``run-security`` without duplicating this logic.
6
+
7
+ **Available Commands:**
8
+
9
+ * ``python manager.py run-linters <package>``
10
+ * ``python manager.py run-linters core_dev_tools --tool ruff``
11
+ * ``python manager.py run-linters core_dev_tools --tool mypy --tool pyright``
12
+ * ``python manager.py run-security <package>``
13
+ """
14
+
15
+ from __future__ import annotations
16
+
17
+ import subprocess # nosec B404
18
+ import sys
19
+
20
+ from click import argument, echo, option
21
+ from click.decorators import group
22
+
23
+ LINTERS: list[tuple[str, list[str]]] = [
24
+ ("ty", ["ty", "check"]),
25
+ ("ruff", ["ruff", "check"]),
26
+ ("mypy", ["mypy", "--explicit-package-bases"]),
27
+ ("pyright", ["pyright"]),
28
+ ("pylint", ["pylint"]),
29
+ ]
30
+
31
+ _LINTER_NAMES = [name for name, _ in LINTERS]
32
+
33
+ # Third element indicates whether the tool accepts a package path argument.
34
+ SECURITY_TOOLS: list[tuple[str, list[str], bool]] = [
35
+ ("bandit", ["bandit", "-r"], True),
36
+ ("pip-audit", ["pip-audit"], False),
37
+ ]
38
+
39
+
40
+ @group()
41
+ def cli_dev():
42
+ """
43
+ Group of commands related to linters and type checkers.
44
+ """
45
+
46
+
47
+ @cli_dev.command("run-linters")
48
+ @argument("package")
49
+ @option(
50
+ "-t",
51
+ "--tool",
52
+ "tools",
53
+ multiple=True,
54
+ type=str,
55
+ help="Run only the specified linter(s). Can be repeated. "
56
+ f"Available: {', '.join(_LINTER_NAMES)}. Defaults to all.",
57
+ )
58
+ def run_linters(package: str, tools: tuple[str, ...]) -> None:
59
+ """
60
+ Runs linters and type checkers against PACKAGE.
61
+
62
+ :param package: Root package directory to check (e.g. ``core_dev_tools``).
63
+ :param tools: Subset of linters to run. When omitted, all linters run.
64
+
65
+ By default, runs all five tools in order:
66
+ - ty check
67
+ - ruff check
68
+ - mypy
69
+ - pyright
70
+ - pylint
71
+
72
+ All linters always run; a non-zero exit from any tool is collected and
73
+ reported at the end, then the command exits with code 1.
74
+ """
75
+
76
+ invalid = set(tools) - set(_LINTER_NAMES)
77
+ if invalid:
78
+ echo(
79
+ f"Unknown linter(s): {', '.join(sorted(invalid))}. "
80
+ f"Available: {', '.join(_LINTER_NAMES)}",
81
+ err=True,
82
+ )
83
+ sys.exit(1)
84
+
85
+ selected = [(name, cmd) for name, cmd in LINTERS if not tools or name in tools]
86
+
87
+ failed: list[str] = []
88
+
89
+ for name, base_cmd in selected:
90
+ echo(f"\n--- {name} ---")
91
+ result = subprocess.run(base_cmd + [package], check=False) # nosec B603
92
+ if result.returncode != 0:
93
+ failed.append(name)
94
+
95
+ echo("")
96
+ if failed:
97
+ echo(f"Linters failed: {', '.join(failed)}", err=True)
98
+ sys.exit(1)
99
+
100
+ echo("All linters passed.")
101
+
102
+
103
+ @cli_dev.command("run-security")
104
+ @argument("package")
105
+ def run_security(package: str) -> None:
106
+ """
107
+ Runs security scanners against PACKAGE.
108
+
109
+ :param package: Root package directory to scan (e.g. ``core_dev_tools``).
110
+
111
+ Runs in order:
112
+ - bandit -r <package>
113
+ - pip-audit
114
+
115
+ All tools always run; a non-zero exit from any tool is collected and
116
+ reported at the end, then the command exits with code 1.
117
+ """
118
+
119
+ failed: list[str] = []
120
+
121
+ for name, base_cmd, takes_path in SECURITY_TOOLS:
122
+ echo(f"\n--- {name} ---")
123
+ cmd = base_cmd + ([package] if takes_path else [])
124
+ result = subprocess.run(cmd, check=False) # nosec B603
125
+ if result.returncode != 0:
126
+ failed.append(name)
127
+
128
+ echo("")
129
+ if failed:
130
+ echo(f"Security tools failed: {', '.join(failed)}", err=True)
131
+ sys.exit(1)
132
+
133
+ 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.1
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.1"
13
13
 
14
14
  authors = [
15
15
  {name = "Alejandro Cora González", email = "alek.cora.glez@gmail.com"}
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  from setuptools import setup
4
2
 
5
-
6
3
  setup()
File without changes
File without changes