Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #570

Merged
merged 4 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/pre-commit/mirrors-prettier
rev: ffb6a759a979008c0e6dff86e39f4745a2d9eac4 # frozen: v3.1.0
rev: f12edd9c7be1c20cfa42420fd0e6df71e42b51ea # frozen: v4.0.0-alpha.8
jarrodmillman marked this conversation as resolved.
Show resolved Hide resolved
hooks:
- id: prettier
types_or: [yaml, toml, markdown, css, scss, javascript, json]
args: [--prose-wrap=preserve]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "f8a3f8c471fb698229face5ed7640a64900b781e" # frozen: v0.4.4
rev: "1dc9eb131c2ea4816c708e4d85820d2cc8542683" # frozen: v0.5.0
hooks:
- id: ruff
args: ["--fix", "--show-fixes", "--exit-non-zero-on-fix"]
Expand Down
17 changes: 8 additions & 9 deletions numpydoc/docscrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,23 +711,22 @@ def properties(self):

@staticmethod
def _should_skip_member(name, klass):
if (
return (
# Namedtuples should skip everything in their ._fields as the
# docstrings for each of the members is: "Alias for field number X"
issubclass(klass, tuple)
and hasattr(klass, "_asdict")
and hasattr(klass, "_fields")
and name in klass._fields
):
return True
return False
)

def _is_show_member(self, name):
if self.show_inherited_members:
return True # show all class members
if name not in self._cls.__dict__:
return False # class member is inherited, we do not show it
return True
return (
# show all class members
self.show_inherited_members
# or class member is not inherited
or name in self._cls.__dict__
)


def get_doc_object(
Expand Down
2 changes: 1 addition & 1 deletion numpydoc/docscrape_sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def _str_references(self):
out += [".. only:: latex", ""]
items = []
for line in self["References"]:
m = re.match(r".. \[([a-z0-9._-]+)\]", line, re.I)
m = re.match(r".. \[([a-z0-9._-]+)\]", line, re.IGNORECASE)
if m:
items.append(m.group(1))
out += [" " + ", ".join([f"[{item}]_" for item in items]), ""]
Expand Down
2 changes: 1 addition & 1 deletion numpydoc/hooks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def find_project_root(srcs: Sequence[str]):
`Black <https://github.com/psf/black/blob/main/src/black/files.py>`_.
"""
if not srcs:
return Path().resolve(), "current directory"
return Path.cwd(), "current directory"

common_path = Path(
os.path.commonpath([Path(src).expanduser().resolve() for src in srcs])
Expand Down
6 changes: 4 additions & 2 deletions numpydoc/numpydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def rename_references(app, what, name, obj, options, lines):
references = set()
for line in lines:
line = line.strip()
m = re.match(r"^\.\. +\[(%s)\]" % app.config.numpydoc_citation_re, line, re.I)
m = re.match(
r"^\.\. +\[(%s)\]" % app.config.numpydoc_citation_re, line, re.IGNORECASE
)
if m:
references.add(m.group(1))

Expand Down Expand Up @@ -185,7 +187,7 @@ def mangle_docstrings(app, what, name, obj, options, lines):
if what == "module":
# Strip top title
pattern = "^\\s*[#*=]{4,}\\n[a-z0-9 -]+\\n[#*=]{4,}\\s*"
title_re = re.compile(pattern, re.I | re.S)
title_re = re.compile(pattern, re.IGNORECASE | re.DOTALL)
lines[:] = title_re.sub("", u_NL.join(lines)).split(u_NL)
else:
try:
Expand Down
2 changes: 1 addition & 1 deletion numpydoc/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

DIRECTIVES = ["versionadded", "versionchanged", "deprecated"]
DIRECTIVE_PATTERN = re.compile(
r"^\s*\.\. ({})(?!::)".format("|".join(DIRECTIVES)), re.I | re.M
r"^\s*\.\. ({})(?!::)".format("|".join(DIRECTIVES)), re.IGNORECASE | re.MULTILINE
)
ALLOWED_SECTIONS = [
"Parameters",
Expand Down