Skip to content

Pin ruff version and prep for v0.0.12 release #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 2, 2024
Merged
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
hooks:
- id: ruff
name: Ruff
entry: ruff
entry: ruff check
args: [--fix, --exit-non-zero-on-fix]
types: [python]
language: system
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ update-lockfiles:
.PHONY: format
format:
black $(sources)
ruff $(sources) --fix --exit-zero
ruff format $(sources)

.PHONY: lint
lint:
black $(sources) --check --diff
ruff $(sources)
ruff check $(sources) --fix

.PHONY: test
test:
Expand Down
18 changes: 12 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ dynamic = ['version']
dependencies = [
'pytest>=7',
'black>=23',
'ruff>=0.0.258',
'ruff>=0.5.0',
]

[project.entry-points.pytest11]
Expand All @@ -64,12 +64,18 @@ xfail_strict = true

[tool.ruff]
line-length = 120
exclude = ['cases_update']
extend-select = ['Q', 'RUF100', 'C90', 'UP', 'I']
flake8-quotes = {inline-quotes = 'single', multiline-quotes = 'double'}
mccabe = { max-complexity = 14 }
isort = { known-first-party = ['pytest_examples'] }
target-version = 'py37'
exclude = ['cases_update']
lint.extend-ignore = [
'E721', # using type() instead of isinstance() - we use this in tests
]
lint.extend-select = ['Q', 'RUF100', 'C90', 'UP', 'I']
lint.flake8-quotes = {inline-quotes = 'single', multiline-quotes = 'double'}
lint.mccabe = { max-complexity = 14 }
lint.isort = { known-first-party = ['pytest_examples'] }

[tool.ruff.format]
quote-style = 'single'

[tool.coverage.run]
source = ['pytest_examples']
Expand Down
2 changes: 1 addition & 1 deletion pytest_examples/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .eval_example import EvalExample
from .find_examples import CodeExample, find_examples

__version__ = '0.0.11'
__version__ = '0.0.12'
__all__ = 'find_examples', 'CodeExample', 'EvalExample'


Expand Down
2 changes: 1 addition & 1 deletion pytest_examples/run_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def _insert_print_args(

comment_prefix = '#> '
comment_prefix_re = re.compile(f'^ *{re.escape(comment_prefix)}', re.MULTILINE)
triple_quotes_prefix_re = re.compile('^ *(?:"{3}|\'{3})', re.MULTILINE)
triple_quotes_prefix_re = re.compile("^ *(?:\"{3}|'{3})", re.MULTILINE)


def find_print_line(lines: list[str], line_no: int) -> int:
Expand Down
2 changes: 1 addition & 1 deletion requirements/linting.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
black
ruff
ruff>=0.5.0
# last version that supports 3.7
pre-commit==2.21.0
8 changes: 3 additions & 5 deletions requirements/linting.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --output-file=requirements/linting.txt --resolver=backtracking requirements/linting.in
# pip-compile --output-file=requirements/linting.txt requirements/linting.in
#
black==23.1.0
# via -r requirements/linting.in
Expand Down Expand Up @@ -32,10 +32,8 @@ pre-commit==2.21.0
# via -r requirements/linting.in
pyyaml==6.0
# via pre-commit
ruff==0.0.258
ruff==0.5.0
# via -r requirements/linting.in
tomli==2.0.1
# via black
virtualenv==20.21.0
# via pre-commit

Expand Down
12 changes: 4 additions & 8 deletions requirements/pyproject.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --output-file=requirements/pyproject.txt --resolver=backtracking pyproject.toml
# pip-compile --output-file=requirements/pyproject.txt pyproject.toml
#
attrs==22.2.0
# via pytest
black==23.1.0
# via pytest-examples (pyproject.toml)
click==8.1.3
# via black
exceptiongroup==1.1.1
# via pytest
iniconfig==2.0.0
# via pytest
mypy-extensions==1.0.0
Expand All @@ -28,7 +26,5 @@ pluggy==1.0.0
# via pytest
pytest==7.2.2
# via pytest-examples (pyproject.toml)
tomli==2.0.1
# via
# black
# pytest
ruff==0.5.0
# via pytest-examples (pyproject.toml)
2 changes: 1 addition & 1 deletion requirements/testing.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pytest-pretty
coverage
ruff
ruff>=0.5.0
8 changes: 2 additions & 6 deletions requirements/testing.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --output-file=requirements/testing.txt requirements/testing.in
#
coverage==7.2.2
# via -r requirements/testing.in
exceptiongroup==1.1.1
# via pytest
iniconfig==2.0.0
# via pytest
markdown-it-py==2.2.0
Expand All @@ -26,7 +24,5 @@ pytest-pretty==1.1.1
# via -r requirements/testing.in
rich==13.3.2
# via pytest-pretty
ruff==0.0.258
ruff==0.5.0
# via -r requirements/testing.in
tomli==2.0.1
# via pytest
21 changes: 11 additions & 10 deletions tests/test_run_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,17 @@ def test_find_run_examples(example: CodeExample, eval_example: EvalExample):

output = '\n'.join(result.outlines)
output = re.sub(r'(=|_){3,}', r'\1\1\1', output)
assert (
'=== FAILURES ===\n'
'___ test_find_run_examples[my_file.md:1-4] ___\n'
'ruff failed:\n'
' my_file.md:2:8: F401 [*] `sys` imported but unused\n'
' my_file.md:3:7: F821 Undefined name `missing`\n'
' Found 2 errors.\n'
' [*] 1 potentially fixable with the --fix option.\n'
'=== short test summary info ===\n'
) in output
for phrase in [
'=== FAILURES ===\n',
'___ test_find_run_examples[my_file.md:1-4] ___\n',
'ruff failed:\n',
' my_file.md:2:8: F401 [*] `sys` imported but unused\n',
' my_file.md:3:7: F821 Undefined name `missing`\n',
' Found 2 errors.\n',
' [*] 1 fixable with the `--fix` option.\n',
'=== short test summary info ===\n',
]:
assert phrase in output


def test_black_ok(pytester: pytest.Pytester):
Expand Down
Loading