Skip to content

Commit d94d5b2

Browse files
committed
style: Replace isinstance calls that use tuples to the | operator as per ruff UP038
1 parent ca0c0f7 commit d94d5b2

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

numpydoc/docscrape.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ def properties(self):
701701
and not self._should_skip_member(name, self._cls)
702702
and (
703703
func is None
704-
or isinstance(func, (property, cached_property))
704+
or isinstance(func, property | cached_property)
705705
or inspect.isdatadescriptor(func)
706706
)
707707
and self._is_show_member(name)

numpydoc/hooks/validate_docstrings.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def name(self) -> str:
6363

6464
@property
6565
def is_function_or_method(self) -> bool:
66-
return isinstance(self.node, (ast.FunctionDef, ast.AsyncFunctionDef))
66+
return isinstance(self.node, ast.FunctionDef | ast.AsyncFunctionDef)
6767

6868
@property
6969
def is_mod(self) -> bool:
@@ -236,7 +236,7 @@ def visit(self, node: ast.AST) -> None:
236236
The node to visit.
237237
"""
238238
if isinstance(
239-
node, (ast.Module, ast.ClassDef, ast.FunctionDef, ast.AsyncFunctionDef)
239+
node, ast.Module | ast.ClassDef | ast.FunctionDef | ast.AsyncFunctionDef
240240
):
241241
self.stack.append(node)
242242

@@ -395,8 +395,8 @@ def process_file(filepath: os.PathLike, config: dict) -> "list[list[str]]":
395395
def run_hook(
396396
files: List[str],
397397
*,
398-
config: Union[Dict[str, Any], None] = None,
399-
ignore: Union[List[str], None] = None,
398+
config: Dict[str, Any] | None = None,
399+
ignore: List[str] | None = None,
400400
) -> int:
401401
"""
402402
Run the numpydoc validation hook.

numpydoc/numpydoc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def _is_cite_in_numpydoc_docstring(citation_node):
8888
section_node = citation_node.parent
8989

9090
def is_docstring_section(node):
91-
return isinstance(node, (section, desc_content))
91+
return isinstance(node, section | desc_content)
9292

9393
while not is_docstring_section(section_node):
9494
section_node = section_node.parent

0 commit comments

Comments
 (0)