Skip to content
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

Migrate to ruff #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
18 changes: 12 additions & 6 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ jobs:
coverage run -m pytest --verbose
coverage report *.py

- name: Check code style
run: pycodestyle .
- name: Lint check
uses: chartboost/ruff-action@v1

- name: Check python file for typical errors
run: pyflakes .
- name: Format check
uses: chartboost/ruff-action@v1
with:
args: 'format --check'

# type annotation checks
- name: Type checks
Expand All @@ -42,5 +44,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Lint markdown files
uses: actionshub/markdownlint@main
- name: markdownlint-cli
uses: nosborn/[email protected]
with:
files: "**/*.md"
config_file: .markdownlint.yaml
dot: true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@ dmypy.json

# Pyre type checker
.pyre/

# Mac
.DS_Store
4 changes: 4 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MD013: false # Line length
MD007: # Unordered list indentation
indent: 4
MD051: false # Link fragments should be valid
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ enough for educational purposes.
## Changelog

- 29.03.2022 - 2
- Add test coverage.
- Add test coverage.
- 29.03.2022 - 1
- Update README. Add formal sections.
- Update README. Add formal sections.
- 29.03.2022 - 0
- Initial
- Initial

## Design notes

Expand Down
2 changes: 1 addition & 1 deletion foo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Foo(object):
class Foo:
def hello(self):
return "hello"

Expand Down
8 changes: 4 additions & 4 deletions foo_test.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import unittest
from hypothesis import given, strategies

from hypothesis import given, strategies

from foo import Foo


class TestFoo(unittest.TestCase):

def test_hello(self):
self.assertEqual(Foo().hello(), "hello")
assert Foo().hello() == "hello"

@given(strategies.integers(), strategies.integers())
def test_add_commutative(self, a, b):
self.assertEqual(Foo().add(a, b), Foo().add(b, a))
assert Foo().add(a, b) == Foo().add(b, a)
56 changes: 56 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[tool.ruff]
line-length = 120
select = [
# A set of chosen linter rules is specified here.
# See https://beta.ruff.rs/docs/rules/ for more info.
# pyflakes (simple obvious errors)
"F",
# pycodestyle (style linter, pep8, black-compatible)
"E",
"W",
# pep8-naming (style linter, pep8 naming conventions)
"N",
# isort (imports sorting)
"I",
# mccabe (cyclomatic complexity analyzer to prevent overcomplicated functions)
"C90",
# pyupgrade (possible syntax upgrades checker)
"UP",
# eradicate (commented-out code finder for it to be removed)
"ERA",
# flake8-2020 (errors related to sys.version or sys.version_info, just in case)
"YTT",
# flake8-annotations (enforces presense of type hints so the codebase is fully typed)
# "ANN", # too burdensome
# flake8-async (async-related mistakes/errors)
"ASYNC",
# flake8-builtins (checks builtin names shadowing, it's better not to)
"A",
# flake8-commas (to enforce trailing commas)
"COM",
# flake8-future-annotations (to ensure enabling modern (3.7+) postponed evaluation of type hints)
"FA",
# flake8-import-conventions (to enforce standartized import aliases like "import pandas as pd")
"ICN",
# flake8-no-pep420 (to enforce presence of __init__.py in packages)
"INP",
# flake8-print (to disallow print statements)
"T20",
# flake8-pytest-style (to improve pytest-related style consistency)
"PT",
# flake8-quotes (to enforce quotes style)
"Q",
# flake8-return (checks mistakes related to return values)
"RET",
# flake8-use-pathlib (to enforce pathlib usage instead of os.path)
"PTH",
# pandas-vet (pandas-related advices)
"PD",
# tryceratops (try/except-related advices)
"TRY",
# ruff-specific advices
"RUF",
]
ignore = [
"COM812", # The following rules may cause conflicts when used with the formatter: `COM812`.
]
Loading