diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cd7c3531..425c165f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,7 +25,7 @@ repos: 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"] diff --git a/numpydoc/docscrape.py b/numpydoc/docscrape.py index a241dc21..f3b4a0ce 100644 --- a/numpydoc/docscrape.py +++ b/numpydoc/docscrape.py @@ -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( diff --git a/numpydoc/docscrape_sphinx.py b/numpydoc/docscrape_sphinx.py index 64588f55..ed389fb4 100644 --- a/numpydoc/docscrape_sphinx.py +++ b/numpydoc/docscrape_sphinx.py @@ -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]), ""] diff --git a/numpydoc/hooks/utils.py b/numpydoc/hooks/utils.py index 448e1245..6f40c69c 100644 --- a/numpydoc/hooks/utils.py +++ b/numpydoc/hooks/utils.py @@ -31,7 +31,7 @@ def find_project_root(srcs: Sequence[str]): `Black `_. """ 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]) diff --git a/numpydoc/numpydoc.py b/numpydoc/numpydoc.py index 2a8e1066..a04443b3 100644 --- a/numpydoc/numpydoc.py +++ b/numpydoc/numpydoc.py @@ -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)) @@ -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: diff --git a/numpydoc/validate.py b/numpydoc/validate.py index c0409c71..138e9d48 100644 --- a/numpydoc/validate.py +++ b/numpydoc/validate.py @@ -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",