Skip to content

Commit

Permalink
ci(ruff): Automated fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tony committed Jul 1, 2023
1 parent 79f5d56 commit 639f647
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 29 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@

def linkcode_resolve(
domain: str, info: t.Dict[str, str]
) -> t.Union[None, str]: # NOQA: C901
) -> t.Union[None, str]:
"""
Determine the URL corresponding to Python object
Expand Down
14 changes: 4 additions & 10 deletions src/doctest_docutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def find(
if name is None:
raise ValueError(
"DocTestFinder.find: name must be given "
"when string.__name__ doesn't exist: %r" % (type(string),)
"when string.__name__ doesn't exist: {!r}".format(type(string))
)

# No access to a loader, so assume it's a normal
Expand All @@ -240,10 +240,7 @@ def find(
source_lines = None

# Initialize globals, and merge in extraglobs.
if globs is None:
globs = {}
else:
globs = globs.copy()
globs = {} if globs is None else globs.copy()
if extraglobs is not None:
globs.update(extraglobs)
if "__name__" not in globs:
Expand Down Expand Up @@ -346,7 +343,7 @@ def condition(node: Node) -> bool:
test_name = node.get("groups")
if isinstance(test_name, list):
test_name = test_name[0]
if test_name is None or "default" == test_name:
if test_name is None or test_name == "default":
test_name = f"{name}[{idx}]"
logger.debug(f"() node: {test_name}")
test = self._get_test(
Expand Down Expand Up @@ -411,10 +408,7 @@ def testdocutils(
name = os.path.basename(filename)

# Assemble the globals.
if globs is None:
globs = {}
else:
globs = globs.copy()
globs = {} if globs is None else globs.copy()
if extraglobs is not None:
globs.update(extraglobs)
if "__name__" not in globs:
Expand Down
9 changes: 2 additions & 7 deletions src/pytest_doctest_docutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@
from pathlib import Path
from typing import TYPE_CHECKING, Any, Iterable, Optional, Tuple, Type

import pytest

import _pytest
import pytest
from _pytest import outcomes
from _pytest.outcomes import OutcomeException

from doctest_docutils import DocutilsDocTestFinder, setup

if TYPE_CHECKING:
Expand Down Expand Up @@ -97,10 +95,7 @@ def _is_doctest(config: pytest.Config, path: Path, parent: pytest.Collector) ->
if path.suffix in (".rst", ".md") and parent.session.isinitpath(path):
return True
globs = config.getoption("doctestglob") or ["*.rst", "*.md"]
for glob in globs:
if path.match(path_pattern=glob):
return True
return False
return any(path.match(path_pattern=glob) for glob in globs)


def _init_runner_class() -> Type["doctest.DocTestRunner"]:
Expand Down
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import typing as t

import pytest

from sphinx.testing.path import path as sphinx_path

pytest_plugins = ["sphinx.testing.fixtures", "pytester"]
Expand Down
5 changes: 1 addition & 4 deletions tests/test_doctest_docutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import textwrap
import typing as t

import pytest

import doctest_docutils
import pytest

FixtureFileDict = t.Dict[str, str]

Expand Down Expand Up @@ -206,7 +205,6 @@ def test_DocutilsDocTestFinder(
elif file_path_mode != "relative":
raise NotImplementedError(f"No file_path_mode supported for {file_path_mode}")

# Setup: Files
tests_path.mkdir()
for file_name, text in files.items():
rst_file = tests_path / file_name
Expand All @@ -215,7 +213,6 @@ def test_DocutilsDocTestFinder(
encoding="utf-8",
)

# Setup: Environment
if file_path_mode == "relative":
monkeypatch.chdir(tests_path)

Expand Down
1 change: 0 additions & 1 deletion tests/test_linkify_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import typing as t

import pytest

from sphinx.testing.util import SphinxTestApp

if t.TYPE_CHECKING:
Expand Down
6 changes: 1 addition & 5 deletions tests/test_pytest_doctest_docutils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import textwrap
import typing as t

import pytest

import _pytest.pytester
import pytest

FixtureFileDict = t.Dict[str, str]

Expand Down Expand Up @@ -216,7 +215,6 @@ def test_pluginDocutilsDocTestFinder(
first_test_key = list(files.keys())[0]
first_test_filename = str(tests_path / first_test_key)

# Setup: Files
tests_path.mkdir()
for file_name, text in files.items():
rst_file = tests_path / file_name
Expand Down Expand Up @@ -284,7 +282,6 @@ def hello(statement: str) -> None:
first_test_key = list(files.keys())[0]
first_test_filename = str(tests_path / first_test_key)

# Setup: Files
tests_path.mkdir()
for file_name, text in files.items():
rst_file = tests_path / file_name
Expand Down Expand Up @@ -376,7 +373,6 @@ def add(a: int, b: int) -> int:
first_test_key = list(files.keys())[0]
first_test_filename = str(tests_path / first_test_key)

# Setup: Files
tests_path.mkdir()
for file_name, text in files.items():
md_file = tests_path / file_name
Expand Down

0 comments on commit 639f647

Please sign in to comment.