ansys-pre-commit-hooks 0.7.2__tar.gz → 0.8.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.
Files changed (43) hide show
  1. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/LICENSE +2 -2
  2. {ansys_pre_commit_hooks-0.7.2/src/ansys_pre_commit_hooks.egg-info → ansys_pre_commit_hooks-0.8.1}/PKG-INFO +43 -22
  3. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/README.rst +28 -9
  4. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/pyproject.toml +32 -21
  5. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/setup.py +13 -11
  6. ansys_pre_commit_hooks-0.8.1/src/ansys/pre_commit_hooks/VERSION +1 -0
  7. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/src/ansys/pre_commit_hooks/__init__.py +1 -1
  8. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/src/ansys/pre_commit_hooks/add_license_headers.py +108 -25
  9. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/src/ansys/pre_commit_hooks/assets/LICENSES/Apache-2.0.txt +1 -1
  10. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/src/ansys/pre_commit_hooks/assets/LICENSES/MIT.txt +1 -1
  11. ansys_pre_commit_hooks-0.8.1/src/ansys/pre_commit_hooks/pyansys_quality_report.py +639 -0
  12. ansys_pre_commit_hooks-0.8.1/src/ansys/pre_commit_hooks/quality_rules/__init__.py +93 -0
  13. ansys_pre_commit_hooks-0.8.1/src/ansys/pre_commit_hooks/quality_rules/cicd.py +383 -0
  14. ansys_pre_commit_hooks-0.8.1/src/ansys/pre_commit_hooks/quality_rules/common.py +267 -0
  15. ansys_pre_commit_hooks-0.8.1/src/ansys/pre_commit_hooks/quality_rules/project_metadata.py +750 -0
  16. ansys_pre_commit_hooks-0.8.1/src/ansys/pre_commit_hooks/quality_rules/readme.py +848 -0
  17. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/src/ansys/pre_commit_hooks/tech_review.py +3 -3
  18. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/src/ansys/pre_commit_hooks/templates/AUTHORS +1 -1
  19. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/src/ansys/pre_commit_hooks/templates/LICENSE +1 -1
  20. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1/src/ansys_pre_commit_hooks.egg-info}/PKG-INFO +43 -22
  21. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/src/ansys_pre_commit_hooks.egg-info/SOURCES.txt +9 -0
  22. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/src/ansys_pre_commit_hooks.egg-info/entry_points.txt +1 -0
  23. ansys_pre_commit_hooks-0.8.1/src/ansys_pre_commit_hooks.egg-info/requires.txt +20 -0
  24. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/tests/test_add_license_headers.py +146 -13
  25. ansys_pre_commit_hooks-0.8.1/tests/test_cicd_rules.py +216 -0
  26. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/tests/test_metadata.py +1 -1
  27. ansys_pre_commit_hooks-0.8.1/tests/test_project_metadata_rules.py +273 -0
  28. ansys_pre_commit_hooks-0.8.1/tests/test_pyansys_quality_report.py +804 -0
  29. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/tests/test_tech_review.py +4 -4
  30. ansys_pre_commit_hooks-0.7.2/src/ansys/pre_commit_hooks/VERSION +0 -1
  31. ansys_pre_commit_hooks-0.7.2/src/ansys_pre_commit_hooks.egg-info/requires.txt +0 -18
  32. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/MANIFEST.in +0 -0
  33. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/setup.cfg +0 -0
  34. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/src/ansys/pre_commit_hooks/assets/.reuse/templates/ansys.jinja2 +0 -0
  35. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/src/ansys/pre_commit_hooks/assets/licenses.json +0 -0
  36. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/src/ansys/pre_commit_hooks/templates/CODE_OF_CONDUCT.md +0 -0
  37. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/src/ansys/pre_commit_hooks/templates/CONTRIBUTING.md +0 -0
  38. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/src/ansys/pre_commit_hooks/templates/CONTRIBUTORS.md +0 -0
  39. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/src/ansys/pre_commit_hooks/templates/README.md +0 -0
  40. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/src/ansys/pre_commit_hooks/templates/README.rst +0 -0
  41. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/src/ansys/pre_commit_hooks/templates/dependabot.yml +0 -0
  42. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/src/ansys_pre_commit_hooks.egg-info/dependency_links.txt +0 -0
  43. {ansys_pre_commit_hooks-0.7.2 → ansys_pre_commit_hooks-0.8.1}/src/ansys_pre_commit_hooks.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 - 2026 ANSYS, Inc. and/or its affiliates.
3
+ Copyright (c) 2023 - 2026 Synopsys, Inc. and ANSYS, Inc. All rights reserved.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
21
+ SOFTWARE.
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ansys-pre-commit-hooks
3
- Version: 0.7.2
3
+ Version: 0.8.1
4
4
  Home-page: https://github.com/ansys/pre-commit-hooks
5
- Author: ANSYS, Inc.
6
- Author-email: "ANSYS, Inc." <pyansys.core@ansys.com>
7
- Maintainer: ANSYS, Inc.
8
- Maintainer-email: "ANSYS, Inc." <pyansys.core@ansys.com>
5
+ Author: Synopsys, Inc. and ANSYS, Inc.
6
+ Author-email: "Synopsys, Inc. and ANSYS, Inc." <pyansys-core@synopsys.com>
7
+ Maintainer: Synopsys, Inc. and ANSYS, Inc.
8
+ Maintainer-email: "Synopsys, Inc. and ANSYS, Inc." <pyansys-core@synopsys.com>
9
9
  License-Expression: MIT
10
10
  Project-URL: Source, https://github.com/ansys/pre-commit-hooks/
11
11
  Project-URL: Issues, https://github.com/ansys/pre-commit-hooks/issues
@@ -24,21 +24,23 @@ Classifier: Programming Language :: Python :: 3.13
24
24
  Requires-Python: >=3.10,<4
25
25
  Description-Content-Type: text/x-rst
26
26
  License-File: LICENSE
27
- Requires-Dist: GitPython==3.1.49
28
- Requires-Dist: importlib-metadata==9.0.0
27
+ Requires-Dist: click==8.5.0
28
+ Requires-Dist: GitPython==3.2.1
29
+ Requires-Dist: importlib-metadata==9.0.1
29
30
  Requires-Dist: Jinja2==3.1.6
30
- Requires-Dist: reuse==6.2.0
31
- Requires-Dist: requests==2.33.1
32
- Requires-Dist: semver==3.0.4
31
+ Requires-Dist: packaging==26.3
32
+ Requires-Dist: reuse==6.3.0
33
+ Requires-Dist: requests==2.34.2
34
+ Requires-Dist: semver==3.1.0
33
35
  Requires-Dist: toml==0.10.2
34
36
  Provides-Extra: doc
35
- Requires-Dist: ansys-sphinx-theme[autoapi]==1.7.2; extra == "doc"
36
- Requires-Dist: numpydoc==1.10.0; extra == "doc"
37
+ Requires-Dist: ansys-sphinx-theme[autoapi]==1.9.0; extra == "doc"
38
+ Requires-Dist: numpydoc==1.11.0; extra == "doc"
37
39
  Requires-Dist: sphinx==8.2.3; extra == "doc"
38
40
  Requires-Dist: sphinx-autodoc-typehints==3.1.0; extra == "doc"
39
41
  Requires-Dist: sphinx-copybutton==0.5.2; extra == "doc"
40
42
  Provides-Extra: tests
41
- Requires-Dist: pytest==9.0.3; extra == "tests"
43
+ Requires-Dist: pytest==9.1.1; extra == "tests"
42
44
  Requires-Dist: pytest-cov==7.1.0; extra == "tests"
43
45
  Dynamic: author
44
46
  Dynamic: classifier
@@ -49,7 +51,7 @@ Dynamic: requires-python
49
51
 
50
52
  Ansys pre-commit hooks
51
53
  ======================
52
- |pyansys| |python| |pypi| |GH-CI| |MIT| |black| |pre-commit-ci|
54
+ |pyansys| |python| |pypi| |GH-CI| |MIT| |ruff| |pre-commit-ci|
53
55
 
54
56
  .. |pyansys| image:: https://img.shields.io/badge/Py-Ansys-ffc107.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABDklEQVQ4jWNgoDfg5mD8vE7q/3bpVyskbW0sMRUwofHD7Dh5OBkZGBgW7/3W2tZpa2tLQEOyOzeEsfumlK2tbVpaGj4N6jIs1lpsDAwMJ278sveMY2BgCA0NFRISwqkhyQ1q/Nyd3zg4OBgYGNjZ2ePi4rB5loGBhZnhxTLJ/9ulv26Q4uVk1NXV/f///////69du4Zdg78lx//t0v+3S88rFISInD59GqIH2esIJ8G9O2/XVwhjzpw5EAam1xkkBJn/bJX+v1365hxxuCAfH9+3b9/+////48cPuNehNsS7cDEzMTAwMMzb+Q2u4dOnT2vWrMHu9ZtzxP9vl/69RVpCkBlZ3N7enoDXBwEAAA+YYitOilMVAAAAAElFTkSuQmCC
55
57
  :target: https://docs.pyansys.com/
@@ -71,9 +73,9 @@ Ansys pre-commit hooks
71
73
  :target: https://opensource.org/licenses/MIT
72
74
  :alt: MIT
73
75
 
74
- .. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg?style=flat
75
- :target: https://github.com/psf/black
76
- :alt: Black
76
+ .. |ruff| image:: https://img.shields.io/badge/code%20style-ruff-D7FF64.svg?style=flat
77
+ :target: https://github.com/astral-sh/ruff
78
+ :alt: Ruff
77
79
 
78
80
  .. |pre-commit-ci| image:: https://results.pre-commit.ci/badge/github/ansys/pre-commit-hooks/main.svg
79
81
  :target: https://results.pre-commit.ci/latest/github/ansys/pre-commit-hooks/main
@@ -87,6 +89,27 @@ The following hooks are currently available:
87
89
  have ``REUSE`` implemented in your repository.
88
90
  * ``tech-review``: Do a technical review of your repository according to
89
91
  `Ansys repository requirements <https://dev.docs.pyansys.com/packaging/structure.html>`_
92
+ * ``pyansys-quality-report``: Check PyAnsys quality
93
+ with selectable rules and a machine-readable JSON report.
94
+
95
+ Configure the quality report in the ``.pre-commit-config.yaml`` file:
96
+
97
+ .. code:: yaml
98
+
99
+ - repo: https://github.com/ansys/pre-commit-hooks
100
+ rev: v0.8.1
101
+ hooks:
102
+ - id: pyansys-quality-report
103
+ args: [--show-all]
104
+ verbose: true
105
+
106
+ Run ``pre-commit run pyansys-quality-report --all-files`` (or ``prek run
107
+ pyansys-quality-report --all-files``) to show warnings and errors.
108
+ Use ``--show-all`` to include passing checks, ``--check RM003`` to select a
109
+ rule, ``--ignore RM004`` to omit one, ``--color never`` for plain output, or
110
+ ``--json`` for JSON output. Colors are enabled by default, including for
111
+ captured output. The current rules and options are documented in the
112
+ `quality report guide <https://pre-commit-hooks.docs.ansys.com/version/stable/getting-started/pyansys-quality-report/index.html>`_.
90
113
 
91
114
  How to install
92
115
  --------------
@@ -199,8 +222,8 @@ These environment commands are provided:
199
222
  Raw testing
200
223
  ^^^^^^^^^^^
201
224
 
202
- If required, you can always call style commands, such as `black`_, `isort`_,
203
- and `flake8`_, or unit testing commands, such as `pytest`_, from the command line.
225
+ If required, you can call ``ruff check --fix .`` and ``ruff format .`` with
226
+ `Ruff`_, or unit testing commands, such as `pytest`_, from the command line.
204
227
  However, calling these commands does not guarantee that your project is
205
228
  being tested in an isolated environment, which is the reason why tools like
206
229
  ``tox`` exist.
@@ -249,9 +272,7 @@ the building requirements and then execute the build module with these commands:
249
272
 
250
273
 
251
274
  .. LINKS AND REFERENCES
252
- .. _black: https://github.com/psf/black
253
- .. _flake8: https://flake8.pycqa.org/en/latest/
254
- .. _isort: https://github.com/PyCQA/isort
275
+ .. _Ruff: https://docs.astral.sh/ruff/
255
276
  .. _pip: https://pypi.org/project/pip/
256
277
  .. _pre-commit: https://pre-commit.com/
257
278
  .. _PyAnsys Developer's Guide: https://dev.docs.pyansys.com/
@@ -1,6 +1,6 @@
1
1
  Ansys pre-commit hooks
2
2
  ======================
3
- |pyansys| |python| |pypi| |GH-CI| |MIT| |black| |pre-commit-ci|
3
+ |pyansys| |python| |pypi| |GH-CI| |MIT| |ruff| |pre-commit-ci|
4
4
 
5
5
  .. |pyansys| image:: https://img.shields.io/badge/Py-Ansys-ffc107.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABDklEQVQ4jWNgoDfg5mD8vE7q/3bpVyskbW0sMRUwofHD7Dh5OBkZGBgW7/3W2tZpa2tLQEOyOzeEsfumlK2tbVpaGj4N6jIs1lpsDAwMJ278sveMY2BgCA0NFRISwqkhyQ1q/Nyd3zg4OBgYGNjZ2ePi4rB5loGBhZnhxTLJ/9ulv26Q4uVk1NXV/f///////69du4Zdg78lx//t0v+3S88rFISInD59GqIH2esIJ8G9O2/XVwhjzpw5EAam1xkkBJn/bJX+v1365hxxuCAfH9+3b9/+////48cPuNehNsS7cDEzMTAwMMzb+Q2u4dOnT2vWrMHu9ZtzxP9vl/69RVpCkBlZ3N7enoDXBwEAAA+YYitOilMVAAAAAElFTkSuQmCC
6
6
  :target: https://docs.pyansys.com/
@@ -22,9 +22,9 @@ Ansys pre-commit hooks
22
22
  :target: https://opensource.org/licenses/MIT
23
23
  :alt: MIT
24
24
 
25
- .. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg?style=flat
26
- :target: https://github.com/psf/black
27
- :alt: Black
25
+ .. |ruff| image:: https://img.shields.io/badge/code%20style-ruff-D7FF64.svg?style=flat
26
+ :target: https://github.com/astral-sh/ruff
27
+ :alt: Ruff
28
28
 
29
29
  .. |pre-commit-ci| image:: https://results.pre-commit.ci/badge/github/ansys/pre-commit-hooks/main.svg
30
30
  :target: https://results.pre-commit.ci/latest/github/ansys/pre-commit-hooks/main
@@ -38,6 +38,27 @@ The following hooks are currently available:
38
38
  have ``REUSE`` implemented in your repository.
39
39
  * ``tech-review``: Do a technical review of your repository according to
40
40
  `Ansys repository requirements <https://dev.docs.pyansys.com/packaging/structure.html>`_
41
+ * ``pyansys-quality-report``: Check PyAnsys quality
42
+ with selectable rules and a machine-readable JSON report.
43
+
44
+ Configure the quality report in the ``.pre-commit-config.yaml`` file:
45
+
46
+ .. code:: yaml
47
+
48
+ - repo: https://github.com/ansys/pre-commit-hooks
49
+ rev: v0.8.1
50
+ hooks:
51
+ - id: pyansys-quality-report
52
+ args: [--show-all]
53
+ verbose: true
54
+
55
+ Run ``pre-commit run pyansys-quality-report --all-files`` (or ``prek run
56
+ pyansys-quality-report --all-files``) to show warnings and errors.
57
+ Use ``--show-all`` to include passing checks, ``--check RM003`` to select a
58
+ rule, ``--ignore RM004`` to omit one, ``--color never`` for plain output, or
59
+ ``--json`` for JSON output. Colors are enabled by default, including for
60
+ captured output. The current rules and options are documented in the
61
+ `quality report guide <https://pre-commit-hooks.docs.ansys.com/version/stable/getting-started/pyansys-quality-report/index.html>`_.
41
62
 
42
63
  How to install
43
64
  --------------
@@ -150,8 +171,8 @@ These environment commands are provided:
150
171
  Raw testing
151
172
  ^^^^^^^^^^^
152
173
 
153
- If required, you can always call style commands, such as `black`_, `isort`_,
154
- and `flake8`_, or unit testing commands, such as `pytest`_, from the command line.
174
+ If required, you can call ``ruff check --fix .`` and ``ruff format .`` with
175
+ `Ruff`_, or unit testing commands, such as `pytest`_, from the command line.
155
176
  However, calling these commands does not guarantee that your project is
156
177
  being tested in an isolated environment, which is the reason why tools like
157
178
  ``tox`` exist.
@@ -200,9 +221,7 @@ the building requirements and then execute the build module with these commands:
200
221
 
201
222
 
202
223
  .. LINKS AND REFERENCES
203
- .. _black: https://github.com/psf/black
204
- .. _flake8: https://flake8.pycqa.org/en/latest/
205
- .. _isort: https://github.com/PyCQA/isort
224
+ .. _Ruff: https://docs.astral.sh/ruff/
206
225
  .. _pip: https://pypi.org/project/pip/
207
226
  .. _pre-commit: https://pre-commit.com/
208
227
  .. _PyAnsys Developer's Guide: https://dev.docs.pyansys.com/
@@ -1,11 +1,11 @@
1
1
  [build-system]
2
2
  requires = [
3
3
  "setuptools>=65.5.1",
4
- "GitPython==3.1.49",
4
+ "GitPython==3.2.1",
5
5
  "Jinja2==3.1.6",
6
- "reuse==6.2.0",
7
- "requests==2.33.1",
8
- "semver==3.0.4",
6
+ "reuse==6.3.0",
7
+ "requests==2.34.2",
8
+ "semver==3.1.0",
9
9
  "toml==0.10.2",
10
10
  "wheel",
11
11
  ]
@@ -17,15 +17,17 @@ dynamic = ["version", "classifiers", "description", "readme", "scripts"]
17
17
  requires-python = ">=3.10,<4"
18
18
  license = "MIT"
19
19
  license-files = ["LICENSE"]
20
- authors = [{ name = "ANSYS, Inc.", email = "pyansys.core@ansys.com" }]
21
- maintainers = [{ name = "ANSYS, Inc.", email = "pyansys.core@ansys.com" }]
20
+ authors = [{ name = "Synopsys, Inc. and ANSYS, Inc.", email = "pyansys-core@synopsys.com" }]
21
+ maintainers = [{ name = "Synopsys, Inc. and ANSYS, Inc.", email = "pyansys-core@synopsys.com" }]
22
22
  dependencies = [
23
- "GitPython==3.1.49",
24
- "importlib-metadata==9.0.0",
23
+ "click==8.5.0",
24
+ "GitPython==3.2.1",
25
+ "importlib-metadata==9.0.1",
25
26
  "Jinja2==3.1.6",
26
- "reuse==6.2.0",
27
- "requests==2.33.1",
28
- "semver==3.0.4",
27
+ "packaging==26.3",
28
+ "reuse==6.3.0",
29
+ "requests==2.34.2",
30
+ "semver==3.1.0",
29
31
  "toml==0.10.2",
30
32
  ]
31
33
 
@@ -47,14 +49,14 @@ classifiers = {file = """
47
49
 
48
50
  [project.optional-dependencies]
49
51
  doc = [
50
- "ansys-sphinx-theme[autoapi]==1.7.2",
51
- "numpydoc==1.10.0",
52
+ "ansys-sphinx-theme[autoapi]==1.9.0",
53
+ "numpydoc==1.11.0",
52
54
  "sphinx==8.2.3",
53
55
  "sphinx-autodoc-typehints==3.1.0",
54
56
  "sphinx-copybutton==0.5.2",
55
57
  ]
56
58
  tests = [
57
- "pytest==9.0.3",
59
+ "pytest==9.1.1",
58
60
  "pytest-cov==7.1.0",
59
61
  ]
60
62
 
@@ -66,14 +68,24 @@ Documentation = "https://pre-commit-hooks.docs.pyansys.com"
66
68
  Releases = "https://github.com/ansys/pre-commit-hooks/releases"
67
69
  Changelog = "https://github.com/ansys/pre-commit-hooks/blob/main/doc/source/changelog.rst"
68
70
 
69
- [tool.black]
71
+ [tool.ruff]
70
72
  line-length = 100
73
+ target-version = "py310"
74
+ src = ["doc", "src", "tests"]
75
+ extend-exclude = ["venv", "doc/_build"]
71
76
 
72
- [tool.isort]
73
- profile = "black"
74
- force_sort_within_sections = true
75
- line_length = 100
76
- src_paths = ["doc", "src", "tests"]
77
+ [tool.ruff.lint]
78
+ select = ["D", "E501", "F401", "F403", "I"]
79
+
80
+ [tool.ruff.lint.per-file-ignores]
81
+ "tests/**" = ["D"]
82
+ "__init__.py" = ["E501", "F401", "F403"]
83
+
84
+ [tool.ruff.lint.isort]
85
+ force-sort-within-sections = true
86
+
87
+ [tool.ruff.lint.pydocstyle]
88
+ convention = "pep257"
77
89
 
78
90
  [tool.codespell]
79
91
  ignore-words = "doc/styles/config/vocabularies/ANSYS/accept.txt"
@@ -148,4 +160,3 @@ showcontent = true
148
160
  directory = "changed"
149
161
  name = "Changed"
150
162
  showcontent = true
151
-
@@ -22,10 +22,10 @@ setup(
22
22
  description=description,
23
23
  long_description=long_description,
24
24
  license="MIT",
25
- author="ANSYS, Inc.",
26
- author_email="pyansys.core@ansys.com",
27
- maintainer="ANSYS, Inc.",
28
- maintainer_email="pyansys.core@ansys.com",
25
+ author="Synopsys, Inc. and ANSYS, Inc.",
26
+ author_email="pyansys-core@synopsys.com",
27
+ maintainer="Synopsys, Inc. and ANSYS, Inc.",
28
+ maintainer_email="pyansys-core@synopsys.com",
29
29
  classifiers=[
30
30
  "Development Status :: 4 - Beta",
31
31
  "Intended Audience :: Science/Research",
@@ -39,25 +39,26 @@ setup(
39
39
  url="https://github.com/ansys/pre-commit-hooks",
40
40
  python_requires=">=3.10,<4",
41
41
  install_requires=[
42
- "GitPython==3.1.49",
43
- "importlib-metadata==9.0.0",
42
+ "click==8.5.0",
43
+ "GitPython==3.2.1",
44
+ "importlib-metadata==9.0.1",
44
45
  "Jinja2==3.1.6",
45
46
  "reuse==6.2.0",
46
- "requests==2.33.1",
47
- "semver==3.0.4",
47
+ "requests==2.34.2",
48
+ "semver==3.1.0",
48
49
  "toml==0.10.2",
49
50
  ],
50
51
  extras_require={
51
52
  "doc": [
52
- "ansys-sphinx-theme[autoapi]==1.7.2",
53
- "numpydoc==1.10.0",
53
+ "ansys-sphinx-theme[autoapi]==1.9.0",
54
+ "numpydoc==1.11.0",
54
55
  "sphinx==8.2.3",
55
56
  "sphinx-autodoc-typehints==3.1.0",
56
57
  "sphinx-copybutton==0.5.2",
57
58
  "sphinx_design==0.6.1",
58
59
  ],
59
60
  "tests": [
60
- "pytest==9.0.3",
61
+ "pytest==9.1.1",
61
62
  "pytest-cov==7.1.0",
62
63
  ],
63
64
  },
@@ -74,6 +75,7 @@ setup(
74
75
  "console_scripts": [
75
76
  "add-license-headers=ansys.pre_commit_hooks.add_license_headers:main",
76
77
  "tech-review=ansys.pre_commit_hooks.tech_review:main",
78
+ "pyansys-quality-report=ansys.pre_commit_hooks.pyansys_quality_report:main",
77
79
  ],
78
80
  },
79
81
  )
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2023 - 2026 ANSYS, Inc. and/or its affiliates.
1
+ # Copyright (C) 2023 - 2026 Synopsys, Inc. and ANSYS, Inc. All rights reserved.
2
2
  # SPDX-License-Identifier: MIT
3
3
  #
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2023 - 2026 ANSYS, Inc. and/or its affiliates.
1
+ # Copyright (C) 2023 - 2026 Synopsys, Inc. and ANSYS, Inc. All rights reserved.
2
2
  # SPDX-License-Identifier: MIT
3
3
  #
4
4
  #
@@ -30,6 +30,7 @@ import argparse
30
30
  from datetime import date as dt
31
31
  import filecmp
32
32
  import io
33
+ from logging import Logger
33
34
  from pathlib import Path
34
35
  import re
35
36
  import shutil
@@ -37,16 +38,76 @@ import sys
37
38
  from tempfile import NamedTemporaryFile
38
39
  from typing import IO, Union
39
40
 
41
+ logger = Logger(__name__)
42
+
40
43
  DEFAULT_TEMPLATE = "ansys"
41
44
  """Default template to use for license headers."""
42
- DEFAULT_COPYRIGHT = "ANSYS, Inc. and/or its affiliates."
45
+ DEFAULT_COPYRIGHT = "Synopsys, Inc. and ANSYS, Inc. All rights reserved."
43
46
  """Default copyright line for license headers."""
44
47
  DEFAULT_LICENSE = "MIT"
45
48
  """Default license for headers."""
46
49
  DEFAULT_START_YEAR = dt.today().year
47
- """Default start year for license headers."""
50
+ """Fallback start year used when git history is unavailable."""
48
51
  YEAR_REGEX = r"(\d{4}) - (\d{4})|\d{4}"
49
52
  """Year regex to match year or year range in files."""
53
+ HEADER_PEEK_BYTES = 1024
54
+ """Number of bytes read from the top of a file to check for an existing license header.
55
+
56
+ License headers always appear at the very start of a file and are at most a few hundred
57
+ bytes, so reading only this many bytes avoids loading the full file for every checked file."""
58
+
59
+
60
+ def get_start_year_from_git(git_repo) -> int:
61
+ """Return the year of the first (oldest) commit in the git repository.
62
+
63
+ Uses ``git log --reverse`` to find the oldest commit and extracts its year.
64
+ When the repository is a shallow clone (e.g. ``fetch-depth: 1`` in CI/CD),
65
+ attempts ``git fetch --unshallow`` to retrieve the full history before
66
+ reading the first commit year. If unshallowing fails (no network access,
67
+ no remote configured, etc.) the function continues with the limited history
68
+ that is locally available.
69
+ Falls back to :data:`DEFAULT_START_YEAR` (the current year) when the
70
+ repository has no commits yet.
71
+
72
+ Parameters
73
+ ----------
74
+ git_repo: git.Repo
75
+ The git repository object.
76
+
77
+ Returns
78
+ -------
79
+ int
80
+ The four-digit year of the first commit, or the current year if the
81
+ repository has no commits.
82
+ """
83
+ # Detect shallow clones produced by CI/CD checkouts with fetch-depth: 1.
84
+ # In that case git log --reverse only sees the single fetched commit, not
85
+ # the true first commit in history.
86
+ try:
87
+ is_shallow = git_repo.git.rev_parse("--is-shallow-repository").strip() == "true"
88
+ except Exception:
89
+ # Older git versions (<2.15) do not support --is-shallow-repository;
90
+ # fall back to checking for the presence of the .git/shallow file.
91
+ is_shallow = (Path(git_repo.git_dir) / "shallow").is_file()
92
+
93
+ if is_shallow:
94
+ # Attempt to retrieve the full history so the real first commit is visible.
95
+ try:
96
+ git_repo.git.fetch("--unshallow")
97
+ except Exception as e:
98
+ # Unshallow can fail when there is no network, no remote is configured,
99
+ # or the server does not support it. Continue with whatever history is
100
+ # available locally.
101
+ logger.debug(f"Failure during unshallow: {e}")
102
+ logger.debug("Continuing with limited history available in shallow clone.")
103
+
104
+ # --reverse makes the oldest commit appear first; %ad is the author date
105
+ first_year_str = (
106
+ git_repo.git.log("--reverse", "--format=%ad", "--date=format:%Y").split("\n")[0].strip()
107
+ )
108
+ if first_year_str and first_year_str.isdigit():
109
+ return int(first_year_str)
110
+ return DEFAULT_START_YEAR
50
111
 
51
112
 
52
113
  def set_lint_args(parser: argparse.ArgumentParser) -> argparse.Namespace:
@@ -90,8 +151,11 @@ def set_lint_args(parser: argparse.ArgumentParser) -> argparse.Namespace:
90
151
  parser.add_argument(
91
152
  "--start_year",
92
153
  type=str,
93
- help="Start year for copyright line in headers.",
94
- default=DEFAULT_START_YEAR,
154
+ help=(
155
+ "Start year for copyright line in headers. "
156
+ "When omitted the year of the first git commit is used automatically."
157
+ ),
158
+ default=None,
95
159
  )
96
160
  # Ignore license check by default is False when action='store_true'
97
161
  parser.add_argument("--ignore_license_check", action="store_true")
@@ -371,7 +435,8 @@ def _has_current_header(file_path: str, copyright: list, years: str) -> bool:
371
435
  file_path: str
372
436
  Path to the file to check.
373
437
  copyright: list
374
- List containing the copyright string. For example, ["ANSYS, Inc. and/or its affiliates."].
438
+ List containing the copyright string. For example,
439
+ ["Synopsys, Inc. and ANSYS, Inc. All rights reserved."].
375
440
  years: str
376
441
  The expected year span. For example, "2023 - 2026" or "2026".
377
442
 
@@ -383,7 +448,7 @@ def _has_current_header(file_path: str, copyright: list, years: str) -> bool:
383
448
  """
384
449
  try:
385
450
  with Path(file_path).open(encoding="utf-8", errors="ignore") as f:
386
- head = f.read(1024)
451
+ head = f.read(HEADER_PEEK_BYTES)
387
452
  except OSError:
388
453
  return False
389
454
 
@@ -410,7 +475,7 @@ def _file_has_license(file_path: str, license: str) -> bool:
410
475
  """
411
476
  try:
412
477
  with Path(file_path).open(encoding="utf-8", errors="ignore") as f:
413
- head = f.read(1024)
478
+ head = f.read(HEADER_PEEK_BYTES)
414
479
  except OSError:
415
480
  return False
416
481
 
@@ -511,9 +576,16 @@ def non_recursive_file_check(
511
576
  add_header(copyright, license, years, file, template, commented, sys.stdout)
512
577
  else:
513
578
  # Check whether the existing SPDX-License-Identifier differs from the
514
- # requested license. If so, strip the old header and write a fresh one
515
- # so that the old identifier is fully replaced rather than merged.
516
- if not existing_license_matches:
579
+ # requested license, or whether the copyright holder phrase has changed.
580
+ # In either case, strip the old header and write a fresh one so that the
581
+ # old lines are fully replaced rather than merged by REUSE's annotate.
582
+ try:
583
+ with Path(file).open(encoding="utf-8", errors="ignore") as _f:
584
+ _head = _f.read(HEADER_PEEK_BYTES)
585
+ except OSError:
586
+ _head = ""
587
+ copyright_holder_changed = copyright[0] not in _head
588
+ if not existing_license_matches or copyright_holder_changed:
517
589
  before_hook = NamedTemporaryFile(mode="w", delete=False).name
518
590
  shutil.copyfile(file, before_hook)
519
591
  _strip_reuse_header(file)
@@ -585,7 +657,8 @@ def update_header(
585
657
  file: str
586
658
  The file whose header is being updated.
587
659
  copyright: str
588
- The copyright string of the header. For example, "ANSYS, Inc. and/or its affiliates."
660
+ The copyright string of the header. For example,
661
+ "Synopsys, Inc. and ANSYS, Inc. All rights reserved."
589
662
  license: str
590
663
  The license of the header. For example, "MIT".
591
664
  years: str
@@ -672,7 +745,7 @@ def add_header(
672
745
  ----------
673
746
  copyright: str
674
747
  The copyright line for the license header. For example,
675
- "ANSYS, Inc. and/or its affiliates."
748
+ "Synopsys, Inc. and ANSYS, Inc. All rights reserved."
676
749
  license: str
677
750
  The license for the license header. For example, "MIT".
678
751
  years: str
@@ -942,17 +1015,6 @@ def main():
942
1015
  # Set changed_headers to zero by default
943
1016
  changed_headers = 0
944
1017
 
945
- # Check start_year is valid
946
- if str(args.start_year).isdigit():
947
- # Check the start year is not later than the current year
948
- if int(args.start_year) > dt.today().year:
949
- raise Exception("Please provide a start year less than or equal to the current year.")
950
- # Check the start year isn't earlier than when computers were created :)
951
- elif int(args.start_year) < 1942:
952
- raise Exception("Please provide a start year greater than or equal to 1942.")
953
- else:
954
- raise Exception("Please ensure the start year is a number.")
955
-
956
1018
  import git
957
1019
 
958
1020
  # Get root directory of the git repository.
@@ -960,6 +1022,27 @@ def main():
960
1022
  # Get the root of the git repository and fix the line separators
961
1023
  git_root = Path(git_repo.git.rev_parse("--show-toplevel"))
962
1024
 
1025
+ # Determine the start year.
1026
+ # When --start_year is explicitly provided, validate and use that value.
1027
+ # Otherwise, auto-detect from the year of the first git commit so that the
1028
+ # original copyright year is never accidentally erased.
1029
+ if args.start_year is not None:
1030
+ if str(args.start_year).isdigit():
1031
+ # Check the start year is not later than the current year
1032
+ if int(args.start_year) > dt.today().year:
1033
+ raise Exception(
1034
+ "Please provide a start year less than or equal to the current year."
1035
+ )
1036
+ # Check the start year isn't earlier than when computers were created :)
1037
+ elif int(args.start_year) < 1942:
1038
+ raise Exception("Please provide a start year greater than or equal to 1942.")
1039
+ else:
1040
+ raise Exception("Please ensure the start year is a number.")
1041
+ start_year = int(args.start_year)
1042
+ else:
1043
+ # Auto-detect: use the year of the repository's first commit
1044
+ start_year = get_start_year_from_git(git_repo)
1045
+
963
1046
  # Create dictionary containing the committed files, custom copyright,
964
1047
  # template, license, changed_headers, year, and git_repo
965
1048
  values = {
@@ -967,7 +1050,7 @@ def main():
967
1050
  "copyright": args.custom_copyright,
968
1051
  "template": args.custom_template,
969
1052
  "license": args.custom_license,
970
- "start_year": int(args.start_year),
1053
+ "start_year": start_year,
971
1054
  "current_year": dt.today().year,
972
1055
  "git_repo": git_repo,
973
1056
  }
@@ -187,7 +187,7 @@
187
187
  same "printed page" as the copyright notice for easier
188
188
  identification within third-party archives.
189
189
 
190
- Copyright {{ year_span }} ANSYS, Inc. and/or its affiliates.
190
+ Copyright {{ year_span }} Synopsys, Inc. and ANSYS, Inc. All rights reserved.
191
191
 
192
192
  Licensed under the Apache License, Version 2.0 (the "License");
193
193
  you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) {{ year_span }} ANSYS, Inc. and/or its affiliates.
3
+ Copyright (c) {{ year_span }} Synopsys, Inc. and ANSYS, Inc. All rights reserved.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in