Skip to content

Commit 7221ea6

Browse files
authored
Increase triple quote search (#61)
* increase lines searched for end of triple quote string * uprev * update uv.lock
1 parent 73e9125 commit 7221ea6

File tree

5 files changed

+234
-255
lines changed

5 files changed

+234
-255
lines changed

pyproject.toml

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ include = ["/README.md", "/Makefile", "/pytest_examples", "/tests"]
99

1010
[project]
1111
name = "pytest-examples"
12-
version = "0.0.17"
12+
version = "0.0.18"
1313
description = "Pytest plugin for testing examples in docstrings and markdown files."
14-
authors = [
15-
{name = "Samuel Colvin", email = "[email protected]"},
16-
]
14+
authors = [{ name = "Samuel Colvin", email = "[email protected]" }]
1715
license = "MIT"
1816
readme = "README.md"
1917
classifiers = [
@@ -36,11 +34,7 @@ classifiers = [
3634
"Topic :: Software Development :: Libraries :: Python Modules",
3735
]
3836
requires-python = ">=3.8"
39-
dependencies = [
40-
"pytest>=7",
41-
"black>=23",
42-
"ruff>=0.5.0",
43-
]
37+
dependencies = ["pytest>=7", "black>=23", "ruff>=0.5.0"]
4438

4539
[project.entry-points.pytest11]
4640
examples = "pytest_examples"
@@ -49,15 +43,8 @@ examples = "pytest_examples"
4943
repository = "https://github.com/pydantic/pytest-examples"
5044

5145
[dependency-groups]
52-
dev = [
53-
"coverage[toml]>=7.6.1",
54-
"pytest-pretty>=1.2.0",
55-
]
56-
lint = [
57-
"pre-commit>=3.5.0",
58-
"pyright>=1.1.389",
59-
"ruff>=0.7.4",
60-
]
46+
dev = ["coverage[toml]>=7.6.1", "pytest-pretty>=1.2.0"]
47+
lint = ["pre-commit>=3.5.0", "pyright>=1.1.389", "ruff>=0.7.4"]
6148

6249
[tool.pytest.ini_options]
6350
testpaths = ["tests", "example"]
@@ -67,22 +54,11 @@ xfail_strict = true
6754
[tool.ruff]
6855
line-length = 120
6956
target-version = "py39"
70-
include = [
71-
"pytest_examples/**/*.py",
72-
"tests/**/*.py",
73-
"examples/**/*.py",
74-
]
57+
include = ["pytest_examples/**/*.py", "tests/**/*.py", "examples/**/*.py"]
7558
exclude = ["tests/cases_update/*.py"]
7659

7760
[tool.ruff.lint]
78-
extend-select = [
79-
"Q",
80-
"RUF100",
81-
"C90",
82-
"UP",
83-
"I",
84-
"D",
85-
]
61+
extend-select = ["Q", "RUF100", "C90", "UP", "I", "D"]
8662
flake8-quotes = { inline-quotes = "single", multiline-quotes = "double" }
8763
isort = { combine-as-imports = true, known-first-party = ["pytest_examples"] }
8864
mccabe = { max-complexity = 15 }
@@ -120,5 +96,8 @@ exclude_lines = [
12096
#typeCheckingMode = "strict"
12197
reportUnnecessaryTypeIgnoreComment = true
12298
reportMissingTypeStubs = false
99+
reportUnusedCallResult = false
100+
reportExplicitAny = false
101+
reportAny = false
123102
include = ["pytest_examples"]
124103
venvPath = ".venv"

pytest_examples/config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ def hash(self) -> str:
4343
return hashlib.md5(str(self).encode()).hexdigest()
4444

4545
def ruff_config(self) -> tuple[str, ...]:
46-
config_lines = []
47-
select = []
48-
ignore = []
49-
args = []
46+
config_lines: list[str] = []
47+
select: list[str] = []
48+
ignore: list[str] = []
49+
args: list[str] = []
5050

5151
# line length is enforced by black
5252
if self.ruff_line_length is None:

pytest_examples/lint.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def ruff_check(
5555
stdout, stderr = p.communicate(example.source, timeout=10)
5656
if p.returncode == 1 and stdout:
5757

58-
def replace_offset(m: re.Match):
58+
def replace_offset(m: re.Match[str]):
5959
line_number = int(m.group(1))
6060
return f'{example.path}:{line_number + example.start_line}'
6161

@@ -88,7 +88,7 @@ def black_check(example: CodeExample, config: ExamplesConfig) -> None:
8888
def code_diff(example: CodeExample, after: str, config: ExamplesConfig) -> str:
8989
diff = black_diff(sub_space(example.source, config), sub_space(after, config), 'before', 'after')
9090

91-
def replace_at_line(match: re.Match) -> str:
91+
def replace_at_line(match: re.Match[str]) -> str:
9292
offset = re.sub(r'\d+', lambda m: str(int(m.group(0)) + example.start_line), match.group(2))
9393
return f'{match.group(1)}{offset}{match.group(3)}'
9494

pytest_examples/run_code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def remove_old_print(lines: list[str], line_index: int) -> None:
275275
return
276276

277277
if triple_quotes_prefix_re.search(next_line):
278-
for i in range(2, 100):
278+
for i in range(2, 10_000):
279279
if triple_quotes_prefix_re.search(lines[line_index + i]):
280280
del lines[line_index + 1 : line_index + i + 1]
281281
return

0 commit comments

Comments
 (0)