Skip to content

Commit

Permalink
Merge pull request #9 from bandophahita/ruff
Browse files Browse the repository at this point in the history
implement Ruff
  • Loading branch information
bandophahita authored Feb 15, 2024
2 parents f164c41 + 282a5cb commit 155f036
Show file tree
Hide file tree
Showing 27 changed files with 976 additions and 898 deletions.
16 changes: 5 additions & 11 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-latest]

steps:
Expand All @@ -30,16 +30,10 @@ jobs:
pip install -e .[dev-all]
- name: Lint with black
run: |
black --check --diff screenpy_requests
- name: Lint with isort
black --check --diff .
- name: Lint with ruff
run: |
isort --check-only --diff screenpy_requests
- name: Lint with flake8
run: |
flake8 --exit-zero screenpy_requests
ruff check .
- name: Lint with mypy
run: |
mypy screenpy_requests
- name: Lint with pylint
run: |
pylint screenpy_requests
mypy .
4 changes: 2 additions & 2 deletions .github/workflows/poetry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
max-parallel: 9
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.12"]
os: [ubuntu-latest]
poetry-version: ["1.3.2"]
poetry-version: ["1.6.1"]

steps:
- uses: actions/checkout@v3
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
max-parallel: 9
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-latest]

steps:
Expand All @@ -25,6 +25,7 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Install dev dependencies
run: |
Expand Down
6 changes: 0 additions & 6 deletions .isort.cfg

This file was deleted.

46 changes: 17 additions & 29 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,19 @@
files: 'screenpy_requests/.*'
files: '(screenpy_requests|tests)/.*'
fail_fast: false
repos:
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
language_version: python3.11
- repo: https://github.com/timothycrosley/isort
rev: 5.12.0
hooks:
- id: isort
language_version: python3.11
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
language_version: python3.11
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
hooks:
- id: mypy
language_version: python3.11
additional_dependencies: ["types-requests==2.25.0"]
- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
- repo: https://github.com/psf/black
rev: 24.1.1
hooks:
- id: black
language_version: python3.12
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.2.0
hooks:
- id: ruff
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
language_version: python3.12
additional_dependencies: ["types-requests>=2.25.0"]
33 changes: 32 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,38 @@ update: update_lock_only
check:
poetry check

trunk_screenpy:
poetry add screenpy git+ssh://[email protected]:ScreenPyHQ/screenpy.git#trunk

local_screenpy:
pip uninstall screenpy
pip install -e ~/projects/screenpy

requirements:
poetry export --without-hashes --with dev -f requirements.txt > requirements.txt

.PHONY: sync update_lock_only update check requirements
.PHONY: sync update trunk_screenpy local_screenpy, requirements

black-check:
black --check .

black-fix:
black .

ruff-check:
ruff check .

ruff-fix:
ruff check . --fix --show-fixes

mypy:
mypy .

.PHONY: black-check black-fix ruff-check ruff-fix mypy

pre-check-in: black-check ruff-check mypy

pre-check-in-fix: black-fix ruff-fix mypy

.PHONY: pre-check-in pre-check-in-fix

1 change: 1 addition & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ exclude = (?x)(
disallow_untyped_defs = True

[mypy-tests.*]
disallow_untyped_defs = True
ignore_missing_imports = True
1,247 changes: 576 additions & 671 deletions poetry.lock

Large diffs are not rendered by default.

128 changes: 118 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
[tool.black]
target-version = ['py311']
target-version = ['py312']

extend-exclude = '''
# A regex preceded with ^/ will apply only to files and directories
# in the root of the project.
(
\.idea
| \.git
| \.mypy_cache
| \.tox
| \/docs
| ^/setup.py
)
'''

# This pyproject.toml is setup so it can be used with or without poetry and also
# supports editable installs (PEP 660) without breaking IDE and linter inspection.
Expand Down Expand Up @@ -27,6 +41,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Topic :: Software Development :: Quality Assurance",
Expand All @@ -48,40 +63,35 @@ classifiers = [
python = "^3.8"
screenpy = ">=4.0.2"
requests = ">=2.26.0"
types-requests = "2.25.0"
types-requests = ">=2.26.0"


# convenience packages for development of screenpy_requests only
black = {version = "*", optional = true}
coverage = {version = "*", optional = true}
flake8 = {version = "*", optional = true}
isort = {version = "*", optional = true}
mypy = {version = "*", optional = true}
pre-commit = {version = "*", optional = true}
pylint = {version = "*", optional = true}
pytest = {version = "*", optional = true}
pytest-mock = {version = "*", optional = true}
sphinx = {version = "^6.1.3", optional = true}
ruff = {version = ">=0.2.0", optional = true}
sphinx = {version = "*", optional = true}
tox = {version = "*", optional = true}

[tool.poetry.extras]
dev = [
"pre-commit",
"pylint",
"pytest",
"pytest-mock",
"tox",
]
dev_all = [
"black",
"coverage",
"flake8",
"isort",
"mypy",
"pre-commit",
"pylint",
"pytest",
"pytest-mock",
"ruff",
"sphinx",
"tox",
]
Expand All @@ -94,3 +104,101 @@ test = [
[build-system]
requires = ["poetry-core>=1.2.0"]
build-backend = "poetry.core.masonry.api"


[tool.ruff]
target-version = "py38" # minimum supported version
line-length = 88 # same as Black.

extend-exclude = [
"screenpy_requests/__init__.py",
"screenpy_requests/__version__.py",
"docs",
]

[tool.ruff.lint]
select = [
"A", # flake8-builtins
"ANN", # flake8-annotations # coming back to this one later to compare against mypy
"ARG", # flake8-unused-arguments
"B", # flake8-bugbear
"BLE", # flake8-blind-except
"C4", # flake8-comprehensions
"D", # pydocstyle
"E", # pycodestyle error
"EM", # flake8-errmsg
"ERA", # eradicate
"F", # Pyflakes
"FA", # flake8-future-annotations
"FBT", # flake8-boolean-trap
"FIX", # flake8-fixme
"FLY", # flynt
"I", # isort
"ICN", # flake8-import-conventions
"ISC", # flake8-implicit-str-concat
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PL", # pylint
"PT", # flake8-pytest-style
"Q", # flake8-quotes
"RET", # flake8-return
"RSE", # flake8-raise
"RUF", # ruff specific
"SIM", # flake8-simplify
"T10", # flake8-debugger
"T20", # flake8-print
"TCH", # flake8-type-checking
"TRY", # tryceratops
"UP", # python upgrade
"W", # pycodestyle warning
"YTT", # flake8-2020

# we would like these someday, but not yet
# "FURB", # refurb
]
ignore = [
"D107", # missing __init__ docstring, we do that in the class docstring.
"D203", # one blank line before class docstring, no thanks!
"D212", # multi line summary first line, we want a one line summary.
"ANN101", # missing self annotation, we only annotate self when we return it.
"ANN102", # missing cls annotation, we only annotate cls when we return it.
]

extend-safe-fixes = [
"EM101",
"EM102",
"TCH001", "TCH002", "TCH003", "TCH004",
"C419",
"D200", "D205", "D415",
"PT003", "PT006", "PT018",
"RET504",
"UP006", "UP007",
]

[tool.ruff.lint.per-file-ignores]
"tests/**" = [
"D", # we don't need public-API-polished docstrings in tests.
"FBT", # using a boolean as a test object is useful!
"PLR", # likewise using specific numbers and strings in tests.
]


[tool.ruff.lint.isort]
combine-as-imports = true
split-on-trailing-comma = false
known-first-party = ["screenpy_requests", "tests"]


[tool.ruff.lint.flake8-pytest-style]
mark-parentheses = false


[tool.ruff.lint.pycodestyle]
ignore-overlong-task-comments = true


[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.ruff.lint.flake8-type-checking]
strict = true
4 changes: 1 addition & 3 deletions screenpy_requests/abilities/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
Abilities which enable Actors to use Requests.
"""
"""Abilities which enable Actors to use Requests."""

from .make_api_requests import MakeAPIRequests

Expand Down
Loading

0 comments on commit 155f036

Please sign in to comment.