diff --git a/pytest_examples/config.py b/pytest_examples/config.py index ced2099..ee7f75b 100644 --- a/pytest_examples/config.py +++ b/pytest_examples/config.py @@ -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] = [] @@ -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)}') diff --git a/pytest_examples/lint.py b/pytest_examples/lint.py index 07d22b0..8230b76 100644 --- a/pytest_examples/lint.py +++ b/pytest_examples/lint.py @@ -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)