Skip to content

Commit

Permalink
Merge pull request #96 from nschloe/ruff
Browse files Browse the repository at this point in the history
use ruff
  • Loading branch information
nschloe authored Sep 17, 2023
2 parents 27c3cc9 + e7084c5 commit f58c700
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 28 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml → .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ci
name: tests

on:
push:
Expand All @@ -12,7 +12,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: pre-commit/action@v3.0.0

build:
Expand All @@ -21,23 +21,23 @@ jobs:
strategy:
matrix:
platform: [ubuntu-latest]
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.7", "3.11"]
include:
- platform: macos-latest
python-version: "3.10"
python-version: "3.11"
- platform: windows-latest
python-version: "3.10"
python-version: "3.11"

runs-on: ${{ matrix.platform }}

steps:
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Test with tox
run: |
pip install tox
tox -- --cov pytest_codeblocks --cov-report xml --cov-report term
- uses: codecov/codecov-action@v3
if: ${{ matrix.python-version == '3.10' && matrix.os == 'ubuntu-latest' }}
- uses: codecov/codecov-action@v4-beta
if: ${{ matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest' }}
15 changes: 5 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
repos:
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.290
hooks:
- id: isort
- id: ruff

- repo: https://github.com/psf/black
rev: 22.3.0
rev: 23.9.1
hooks:
- id: black
language_version: python3

- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.6.2
rev: v3.0.3
hooks:
- id: prettier
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2020-2022 Nico Schlömer
Copyright (c) 2020-present Nico Schlömer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

[![gh-actions](https://img.shields.io/github/workflow/status/nschloe/pytest-codeblocks/ci?style=flat-square)](https://github.com/nschloe/pytest-codeblocks/actions?query=workflow%3Aci)
[![codecov](https://img.shields.io/codecov/c/github/nschloe/pytest-codeblocks.svg?style=flat-square)](https://app.codecov.io/gh/nschloe/pytest-codeblocks)
[![LGTM](https://img.shields.io/lgtm/grade/python/github/nschloe/pytest-codeblocks.svg?style=flat-square)](https://lgtm.com/projects/g/nschloe/pytest-codeblocks)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square)](https://github.com/psf/black)

This is pytest-codeblocks, a [pytest](https://pytest.org/) plugin for testing code
Expand Down
7 changes: 3 additions & 4 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ clean:
@rm -rf src/*.egg-info/ build/ dist/ .tox/

format:
isort .
black .
ruff src/ tests/ --fix
black src/ tests/
blacken-docs README.md

lint:
black --check .
flake8 .
pre-commit run --all
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dynamic = ["version"]
requires-python = ">=3.7"
Expand Down
6 changes: 4 additions & 2 deletions src/pytest_codeblocks/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ def extract_from_buffer(f, max_num_lines: int = 10000) -> list[CodeBlock]:

elif keyword == "cont":
if len(out) == 0:
raise RuntimeError(
"Found <!--pytest-codeblocks-cont--> but no previous code block."
msg = (
"Found <!--pytest-codeblocks-cont--> "
"but no previous code block."
)
raise RuntimeError(msg)
continued_block = out[-1]

elif keyword == "skip":
Expand Down
6 changes: 4 additions & 2 deletions src/pytest_codeblocks/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
def pytest_addoption(parser):
group = parser.getgroup("general")
group.addoption(
"--codeblocks", action="store_true", help="enable testing of codeblocks"
"--codeblocks",
action="store_true",
help="enable testing of code blocks",
)


Expand Down Expand Up @@ -46,7 +48,7 @@ def collect(self):
# pytest.mark.skipif(sys.version_info < (3, 10), reason="...")
#
# which needs sys. Import it here.
import sys
import sys # noqa: F401

out.add_marker(eval(mark))

Expand Down

0 comments on commit f58c700

Please sign in to comment.