Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Change log
- Add script ``bin/switch-to-pep420`` to convert a package from the old
namespace package layout to the new PEP 420 native layout.

- Add ``pyupgrade-exclude`` to ``[pre-commit]`` section in ``.meta.toml``.

1.1 (2025-01-29)
----------------
Expand Down
6 changes: 6 additions & 0 deletions docs/narr.rst
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@ updated. Example:

[pre-commit]
teyit-exclude = "App/tests/fixtures/error\.py"
pyupgrade-exclude = "^src/zope/proxy/__init__\.py$"


[readthedocs]
build-extra = [
Expand Down Expand Up @@ -659,6 +661,10 @@ teyit-exclude
Regex for files to be hidden from teyit. It fails on files containing syntax
errors. This option has to be a string and is omitted when not defined.

pyupgrade-exclude
Regex for files to be hidden from pyupgrade. It might be a bit overly
optimistic with its changes. This option has to be a string and is omitted
when not defined.

ReadTheDocs options
```````````````````
Expand Down
3 changes: 3 additions & 0 deletions src/zope/meta/config_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,16 @@ def gitignore(self):

def pre_commit_config_yaml(self):
teyit_exclude = self.meta_cfg["pre-commit"].get("teyit-exclude", "")
pyupgrade_exclude = self.meta_cfg["pre-commit"].get(
"pyupgrade-exclude", "")

self.copy_with_meta(
"pre-commit-config.yaml.j2",
self.path / ".pre-commit-config.yaml",
self.config_type,
oldest_python_version=self.oldest_python.replace(".", ""),
teyit_exclude=teyit_exclude,
pyupgrade_exclude=pyupgrade_exclude,
)

def readthedocs(self):
Expand Down
3 changes: 3 additions & 0 deletions src/zope/meta/default/pre-commit-config.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ repos:
hooks:
- id: pyupgrade
args: [--py%(oldest_python_version)s-plus]
{% if pyupgrade_exclude %}
exclude: %(pyupgrade_exclude)s
{% endif %}
- repo: https://github.com/isidentical/teyit
rev: 0.4.3
hooks:
Expand Down