tox-pre-commit 0.0.1a0__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.
@@ -0,0 +1,95 @@
1
+ """A tox plugin providing a pre-commit environment."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import typing as _t
6
+ from shlex import join as shlex_join
7
+ from textwrap import dedent
8
+
9
+ from tox.config.loader.memory import MemoryLoader
10
+ from tox.plugin import impl
11
+
12
+
13
+ if _t.TYPE_CHECKING:
14
+ from collections import abc as _c # noqa: WPS347
15
+
16
+ from tox.config.sets import ConfigSet
17
+ from tox.session.state import State
18
+
19
+
20
+ _PYTHON_CLI_OPTIONS = (
21
+ 'python',
22
+ '-bb',
23
+ '-E',
24
+ '-s',
25
+ '-I',
26
+ '-Werror',
27
+ )
28
+
29
+
30
+ @impl
31
+ def tox_extend_envs() -> _c.Iterable[str]:
32
+ """Declare the pre-commit environment.
33
+
34
+ :returns: The names of the tox environments this plugin provides.
35
+ """
36
+ return ('pre-commit',)
37
+
38
+
39
+ @impl
40
+ def tox_add_core_config(
41
+ core_conf: ConfigSet, # noqa: ARG001 # pylint: disable=unused-argument
42
+ state: State,
43
+ ) -> None:
44
+ """Inject default configuration for the pre-commit environment.
45
+
46
+ :param core_conf: The core tox configuration set (unused).
47
+ :param state: The tox session state to inject environments into.
48
+ """
49
+ pos_args = state.conf.pos_args(to_path=None)
50
+ pre_commit_args = ('--all-files',) if pos_args is None else pos_args
51
+
52
+ pre_commit_cmd = (
53
+ *_PYTHON_CLI_OPTIONS,
54
+ '-m',
55
+ 'pre_commit',
56
+ 'run',
57
+ '--color=always',
58
+ '--show-diff-on-failure',
59
+ *pre_commit_args,
60
+ )
61
+
62
+ install_advice_cmd = (
63
+ *_PYTHON_CLI_OPTIONS,
64
+ '-c',
65
+ dedent("""\
66
+ cmd = "python -Im pre_commit install"
67
+ scr_width = max(len(cmd) + 10, 80)
68
+ sep = "=" * scr_width
69
+ cmd_str = " $ " + cmd
70
+ print()
71
+ print(sep)
72
+ print("To install pre-commit hooks into the Git repo, run:")
73
+ print()
74
+ print(cmd_str)
75
+ print()
76
+ print(sep)
77
+ """),
78
+ )
79
+
80
+ state.conf.memory_seed_loaders['pre-commit'].append(
81
+ MemoryLoader(
82
+ base=[],
83
+ description=(
84
+ '[tox-pre-commit] Run the quality checks; '
85
+ 'use `SKIP=id1,id2 tox r -e pre-commit` to skip checks; '
86
+ 'use `tox r -e pre-commit -- id1 --all-files` to select checks'
87
+ ),
88
+ deps=['pre-commit'],
89
+ commands_pre=[],
90
+ commands=[shlex_join(pre_commit_cmd)],
91
+ commands_post=[f'-{shlex_join(install_advice_cmd)}'],
92
+ package='skip',
93
+ pass_env=['SKIP'],
94
+ ),
95
+ )
@@ -0,0 +1,80 @@
1
+ Metadata-Version: 2.4
2
+ Name: tox-pre-commit
3
+ Version: 0.0.1a0
4
+ Summary: A tox plugin providing a pre-commit environment
5
+ License-Expression: LicenseRef-MIT-NORUS
6
+ Classifier: Development Status :: 2 - Pre-Alpha
7
+ Classifier: Framework :: tox
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Programming Language :: Python :: 3 :: Only
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Programming Language :: Python :: 3.14
15
+ Classifier: Programming Language :: Python :: 3.15
16
+ Classifier: Topic :: Software Development :: Quality Assurance
17
+ Classifier: Topic :: Software Development :: Testing
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: tox>=4.30
22
+ Dynamic: license-file
23
+
24
+ [![SWUbanner]][SWUdocs]
25
+
26
+ [![tox-dev badge]][tox-dev]
27
+ [![pre-commit.ci status badge]][pre-commit.ci results page]
28
+ [![GH Sponsors badge]][GH Sponsors URL]
29
+
30
+ [SWUbanner]:
31
+ https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner-direct-single.svg
32
+ [SWUdocs]:
33
+ https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md
34
+
35
+ [tox-dev]: https://github.com/tox-dev
36
+ [tox-dev badge]:
37
+ https://img.shields.io/badge/project-yellow?label=tox-dev&labelColor=c3cc39&color=7f833e
38
+
39
+ [pre-commit.ci status badge]:
40
+ https://results.pre-commit.ci/badge/github/tox-dev/tox-pre-commit/main.svg
41
+ [pre-commit.ci results page]:
42
+ https://results.pre-commit.ci/latest/github/tox-dev/tox-pre-commit/main
43
+
44
+ [GH Sponsors badge]:
45
+ https://img.shields.io/badge/%40webknjaz-transparent?logo=githubsponsors&logoColor=%23EA4AAA&label=Sponsor&color=2a313c
46
+ [GH Sponsors URL]:
47
+ https://github.com/sponsors/webknjaz
48
+
49
+
50
+ # tox-pre-commit
51
+
52
+ A tox plugin providing a pre-commit environment.
53
+
54
+
55
+ ## Usage
56
+
57
+ Add `tox-pre-commit` to your project's `tox` requirements -- either
58
+ in `tox.toml`:
59
+
60
+ ```toml
61
+ requires = [
62
+ "tox-pre-commit",
63
+ ]
64
+ ```
65
+
66
+ ...or in `tox.ini`:
67
+
68
+ ```ini
69
+ [tox]
70
+ requires =
71
+ tox-pre-commit
72
+ ```
73
+
74
+ Then invoke the `pre-commit` env that the plugin exposes:
75
+
76
+ ```console
77
+ $ tox run -q -e pre-commit
78
+ $ tox run -q -e pre-commit -- ruff --all-files # narrow with posargs
79
+ $ SKIP=mypy,ruff tox run -q -e pre-commit # skip specific hooks
80
+ ```
@@ -0,0 +1,7 @@
1
+ tox_plugins/pre_commit/_plugin.py,sha256=R-nC1fEEbhestBv-h-TrFUfYtx1UNddkdG5kVWWDyVg,2478
2
+ tox_pre_commit-0.0.1a0.dist-info/licenses/LICENSE,sha256=85SK-PytDx4BwMjFUg_P_2RHNZKCABJai2HQtvRimOg,2097
3
+ tox_pre_commit-0.0.1a0.dist-info/METADATA,sha256=ClJnFqPUHXiHEwoSVynC-Di2t0em4XYMS5fH7MrV5EI,2307
4
+ tox_pre_commit-0.0.1a0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
5
+ tox_pre_commit-0.0.1a0.dist-info/entry_points.txt,sha256=6UV5eXbV_HfEmvYvm-OK1cz7COEhcIdHO5O61JGzN9w,54
6
+ tox_pre_commit-0.0.1a0.dist-info/top_level.txt,sha256=Yj2LDGZgdLnh1_WcouoM_F5NNdx4SK4w-ulaEBzA920,12
7
+ tox_pre_commit-0.0.1a0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [tox]
2
+ tox-pre-commit = tox_plugins.pre_commit._plugin
@@ -0,0 +1,43 @@
1
+ Copyright (c) 2026 Sviatoslav Sydorenko and contributors
2
+
3
+ The following license is modified from the MIT license.
4
+
5
+ MIT-NORUS LICENSE:
6
+
7
+ The following conditions must be met by any person or organization obtaining a copy of this
8
+ software:
9
+
10
+ - You MUST not be affiliated with the Russian government or military.
11
+ - You MUST not financially support Russia, Russian military, or Russian economy.
12
+ - You MUST condemn Russia's genocide against Ukraine.
13
+ - You MUST not do business with Russia or in Russia.
14
+
15
+ By using this software, you publicly agree to the following:
16
+
17
+ - Russian war against Ukraine is a crime against humanity.
18
+ - Russia is responsible for death and destruction in Ukraine.
19
+ - You will not support Russia in any way.
20
+ - The company you work for, or the organization you represent, does not do business with or in Russia.
21
+ - The company you work for, or the organization you represent, was not founded by, nor has it received investments from, Russian citizens.
22
+
23
+ The above conditions shall be included in all copies or substantial portions of the Software.
24
+
25
+ MIT LICENSE:
26
+
27
+ Permission is hereby granted, free of charge, to any person obtaining a copy
28
+ of this software and associated documentation files (the "Software"), to deal
29
+ in the Software without restriction, including without limitation the rights
30
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
31
+ copies of the Software, and to permit persons to whom the Software is
32
+ furnished to do so, subject to the following conditions:
33
+
34
+ The above copyright notice and this permission notice shall be included in all
35
+ copies or substantial portions of the Software.
36
+
37
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
38
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
39
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
40
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
41
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
42
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
43
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ tox_plugins