Skip to content

Commit 54dbc89

Browse files
[pre-commit.ci] pre-commit autoupdate (numpy#570)
2 parents 7bf3172 + 1246ddf commit 54dbc89

File tree

6 files changed

+16
-15
lines changed

6 files changed

+16
-15
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ repos:
2525
args: [--prose-wrap=preserve]
2626

2727
- repo: https://github.com/astral-sh/ruff-pre-commit
28-
rev: "f8a3f8c471fb698229face5ed7640a64900b781e" # frozen: v0.4.4
28+
rev: "1dc9eb131c2ea4816c708e4d85820d2cc8542683" # frozen: v0.5.0
2929
hooks:
3030
- id: ruff
3131
args: ["--fix", "--show-fixes", "--exit-non-zero-on-fix"]

numpydoc/docscrape.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -711,23 +711,22 @@ def properties(self):
711711

712712
@staticmethod
713713
def _should_skip_member(name, klass):
714-
if (
714+
return (
715715
# Namedtuples should skip everything in their ._fields as the
716716
# docstrings for each of the members is: "Alias for field number X"
717717
issubclass(klass, tuple)
718718
and hasattr(klass, "_asdict")
719719
and hasattr(klass, "_fields")
720720
and name in klass._fields
721-
):
722-
return True
723-
return False
721+
)
724722

725723
def _is_show_member(self, name):
726-
if self.show_inherited_members:
727-
return True # show all class members
728-
if name not in self._cls.__dict__:
729-
return False # class member is inherited, we do not show it
730-
return True
724+
return (
725+
# show all class members
726+
self.show_inherited_members
727+
# or class member is not inherited
728+
or name in self._cls.__dict__
729+
)
731730

732731

733732
def get_doc_object(

numpydoc/docscrape_sphinx.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def _str_references(self):
329329
out += [".. only:: latex", ""]
330330
items = []
331331
for line in self["References"]:
332-
m = re.match(r".. \[([a-z0-9._-]+)\]", line, re.I)
332+
m = re.match(r".. \[([a-z0-9._-]+)\]", line, re.IGNORECASE)
333333
if m:
334334
items.append(m.group(1))
335335
out += [" " + ", ".join([f"[{item}]_" for item in items]), ""]

numpydoc/hooks/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def find_project_root(srcs: Sequence[str]):
3131
`Black <https://github.com/psf/black/blob/main/src/black/files.py>`_.
3232
"""
3333
if not srcs:
34-
return Path().resolve(), "current directory"
34+
return Path.cwd(), "current directory"
3535

3636
common_path = Path(
3737
os.path.commonpath([Path(src).expanduser().resolve() for src in srcs])

numpydoc/numpydoc.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ def rename_references(app, what, name, obj, options, lines):
5858
references = set()
5959
for line in lines:
6060
line = line.strip()
61-
m = re.match(r"^\.\. +\[(%s)\]" % app.config.numpydoc_citation_re, line, re.I)
61+
m = re.match(
62+
r"^\.\. +\[(%s)\]" % app.config.numpydoc_citation_re, line, re.IGNORECASE
63+
)
6264
if m:
6365
references.add(m.group(1))
6466

@@ -185,7 +187,7 @@ def mangle_docstrings(app, what, name, obj, options, lines):
185187
if what == "module":
186188
# Strip top title
187189
pattern = "^\\s*[#*=]{4,}\\n[a-z0-9 -]+\\n[#*=]{4,}\\s*"
188-
title_re = re.compile(pattern, re.I | re.S)
190+
title_re = re.compile(pattern, re.IGNORECASE | re.DOTALL)
189191
lines[:] = title_re.sub("", u_NL.join(lines)).split(u_NL)
190192
else:
191193
try:

numpydoc/validate.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
DIRECTIVES = ["versionadded", "versionchanged", "deprecated"]
2525
DIRECTIVE_PATTERN = re.compile(
26-
r"^\s*\.\. ({})(?!::)".format("|".join(DIRECTIVES)), re.I | re.M
26+
r"^\s*\.\. ({})(?!::)".format("|".join(DIRECTIVES)), re.IGNORECASE | re.MULTILINE
2727
)
2828
ALLOWED_SECTIONS = [
2929
"Parameters",

0 commit comments

Comments
 (0)