Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions pytest_examples/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ def hash(self) -> str:

def ruff_config(self) -> tuple[str, ...]:
config_lines: list[str] = []
select: list[str] = []
# Pin ruff's classic default rule set as our base rather than inheriting ruff's evolving defaults:
# ruff 0.16 added `I` (isort) and `FA` (future-annotations) to the defaults, which would silently
# start flagging examples that pytest-examples never opted into. Opt-in flags extend this base.
select: list[str] = ['E4', 'E7', 'E9', 'F']
ignore: list[str] = []
args: list[str] = []

Expand Down Expand Up @@ -76,8 +79,7 @@ def ruff_config(self) -> tuple[str, ...]:
ignore.extend(self.ruff_ignore)

if select:
# use extend to not disable default select
args.append(f'--extend-select={",".join(select)}')
args.append(f'--select={",".join(select)}')
if ignore:
args.append(f'--ignore={",".join(ignore)}')

Expand Down
4 changes: 3 additions & 1 deletion pytest_examples/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ def ruff_check(
extra_ruff_args: tuple[str, ...] = (),
) -> str:
ruff = find_ruff_bin()
args = ruff, 'check', '-', *config.ruff_config(), *extra_ruff_args
# Pin the concise output format: ruff 0.16 made the grouped `full` format the default, which breaks the
# `^-:(\d+)` offset rewriting below and the readable one-line-per-error output.
args = ruff, 'check', '-', '--output-format=concise', *config.ruff_config(), *extra_ruff_args

p = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE, encoding='utf-8')
stdout, stderr = p.communicate(example.source, timeout=10)
Expand Down
Loading