Skip to content

Commit 4fb5d67

Browse files
authored
chore: Sync ruff. (#246)
1 parent b98c536 commit 4fb5d67

File tree

18 files changed

+92
-163
lines changed

18 files changed

+92
-163
lines changed

.pre-commit-config.yaml

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,6 @@ repos:
3737
repo: https://github.com/pre-commit/pre-commit-hooks
3838
rev: v4.4.0
3939
- hooks:
40-
- entry: pipenv run python -m black
41-
id: black
42-
language: system
43-
name: black
44-
types:
45-
- python
46-
- entry: pipenv run python -m isort --filter-files
47-
id: isort
48-
language: system
49-
name: isort
50-
require_serial: true
51-
types_or:
52-
- cython
53-
- pyi
54-
- python
5540
- entry: make mypy
5641
id: mypy
5742
language: system
@@ -60,12 +45,22 @@ repos:
6045
require_serial: true
6146
types:
6247
- python
63-
- entry: pipenv run python -m ruff --force-exclude
48+
- entry: pipenv run python -m ruff check --force-exclude
6449
id: ruff
6550
language: system
6651
name: ruff
67-
types:
52+
require_serial: true
53+
types_or:
54+
- python
55+
- pyi
56+
- entry: pipenv run python -m ruff format --check --force-exclude
57+
id: ruff-format
58+
language: system
59+
name: ruff-format
60+
require_serial: true
61+
types_or:
6862
- python
63+
- pyi
6964
- entry: pipenv run toml-sort
7065
id: toml-sort
7166
language: system

.vscode/extensions.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
"ExecutableBookProject.myst-highlight",
55
"PascalReitermann93.vscode-yaml-sort",
66
"charliermarsh.ruff",
7-
"ms-python.black-formatter",
87
"ms-python.mypy-type-checker",
98
"ms-python.python",
109
"richie5um2.vscode-sort-json",
11-
"streetsidesoftware.code-spell-checker",
12-
"trond-snekvik.simple-rst"
10+
"streetsidesoftware.code-spell-checker"
1311
]
1412
}

.vscode/settings.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
},
88
"[python]": {
99
"editor.codeActionsOnSave": {
10-
"source.organizeImports": true
10+
"source.fixAll.ruff": true,
11+
"source.organizeImports.ruff": true
1112
},
12-
"editor.defaultFormatter": "ms-python.black-formatter"
13+
"editor.defaultFormatter": "charliermarsh.ruff",
14+
"editor.formatOnSave": true
1315
},
1416
"[yaml]": {
1517
"editor.defaultFormatter": "PascalReitermann93.vscode-yaml-sort"
@@ -27,7 +29,6 @@
2729
"genindex",
2830
"huxuan",
2931
"interruptible",
30-
"isort",
3132
"JPKXI",
3233
"maxdepth",
3334
"modindex",

Makefile

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: clean deepclean install dev constraints black isort mypy ruff toml-sort lint pre-commit test-run test build upload docs-autobuild changelog docs-gen docs-mypy docs-coverage docs
1+
.PHONY: clean deepclean install dev constraints mypy ruff ruff-format toml-sort lint pre-commit test-run test build upload docs-autobuild changelog docs-gen docs-mypy docs-coverage docs
22

33
########################################################################################
44
# Variables
@@ -71,28 +71,24 @@ constraints: deepclean
7171
# Lint and pre-commit
7272
########################################################################################
7373

74-
# Check lint with black.
75-
black:
76-
$(PIPRUN) python -m black --check .
77-
78-
# Check lint with isort.
79-
isort:
80-
$(PIPRUN) python -m isort --check .
81-
8274
# Check lint with mypy.
8375
mypy:
8476
$(PIPRUN) python -m mypy .
8577

86-
# Check lint with ruff.
78+
# Lint with ruff.
8779
ruff:
88-
$(PIPRUN) python -m ruff .
80+
$(PIPRUN) python -m ruff check .
81+
82+
# Format with ruff.
83+
ruff-format:
84+
$(PIPRUN) python -m ruff format --check .
8985

9086
# Check lint with toml-sort.
9187
toml-sort:
9288
$(PIPRUN) toml-sort --check pyproject.toml
9389

9490
# Check lint with all linters.
95-
lint: black isort mypy ruff toml-sort
91+
lint: mypy ruff ruff-format toml-sort
9692

9793
# Run pre-commit with autofix against all files.
9894
pre-commit:

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ A Python project template covering the entire development lifecycle with various
1010
[![GitHub](https://img.shields.io/github/license/serious-scaffold/ss-python)](https://github.com/serious-scaffold/ss-python/blob/main/LICENSE)
1111

1212
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)
13-
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
14-
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
1513
[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
1614
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
1715
[![Pydantic v2](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/5697b1e4c4a9790ece607654e6c02a160620c7e1/docs/badge/v2.json)](https://pydantic.dev)
@@ -34,7 +32,7 @@ If you find this helpful, please consider [sponsorship](https://github.com/spons
3432
- Manage [virtual environments](https://docs.python.org/3/glossary.html#term-virtual-environment) for development with [`pipenv`](https://pipenv.pypa.io/).
3533
- Manage dependency with categorized [requirements](https://pip.pypa.io/en/stable/user_guide/#requirements-files) and [constraints](https://pip.pypa.io/en/stable/user_guide/#constraints-files).
3634
- Automate Git hooks with [pre-commit hooks](https://github.com/pre-commit/pre-commit-hooks) and [local](https://pre-commit.com/#repository-local-hooks) linters.
37-
- Lint with [`black`](https://github.com/psf/black), [`isort`](https://pycqa.github.io/isort/), [`mypy`](http://www.mypy-lang.org/), [`ruff`](https://github.com/charliermarsh/ruff), and [`toml-sort`](https://github.com/pappasam/toml-sort).
35+
- Lint with [`mypy`](http://www.mypy-lang.org/), [`ruff`](https://github.com/charliermarsh/ruff), and [`toml-sort`](https://github.com/pappasam/toml-sort).
3836
- Test with [`pytest`](https://pytest.org/) and [`coverage`](https://coverage.readthedocs.io) for threshold and reports.
3937
- Document with [`sphinx`](https://www.sphinx-doc.org/), the [`furo`](https://pradyunsg.me/furo) theme, and [mypy](https://mypy.readthedocs.io/en/stable/command_line.html?report-generation)/[coverage](https://coverage.readthedocs.io/en/7.3.0/cmd.html#html-reporting-coverage-html) reports.
4038
- Version the package using git metadata with [`setuptools-scm`](https://github.com/pypa/setuptools_scm/).

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
1111

1212
author = "huxuan"
13-
copyright = "2023, huxuan" # noqa: A001
13+
copyright = "2023, huxuan"
1414
project = "Serious Scaffold Python"
1515
release = metadata.version("ss-python")
1616
version = ".".join(release.split(".")[:2])

pyproject.toml

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,6 @@ ss-python-cli = "ss_python.cli:app"
4242
homepage = "https://github.com/serious-scaffold/ss-python/"
4343
issue = "https://github.com/serious-scaffold/ss-python/issues"
4444

45-
[tool.black]
46-
force-exclude = '''
47-
(
48-
template/.*
49-
)
50-
'''
51-
5245
[tool.coverage.report]
5346
fail_under = 100
5447

@@ -57,13 +50,6 @@ source = [
5750
"ss_python",
5851
]
5952

60-
[tool.isort]
61-
color_output = true
62-
extend_skip = [
63-
"template",
64-
]
65-
profile = "black"
66-
6753
[tool.mypy]
6854
check_untyped_defs = true
6955
disallow_any_unimported = true
@@ -92,27 +78,28 @@ extend-exclude = [
9278
"template",
9379
]
9480
fix = true
95-
ignore = [
96-
# https://docs.astral.sh/ruff/rules/#pydocstyle-d
97-
"D203",
98-
"D204",
99-
"D213",
100-
"D215",
101-
"D400",
102-
"D404",
103-
"D406",
104-
"D407",
105-
"D408",
106-
"D409",
107-
"D413",
108-
]
109-
select = ["ALL"]
11081
src = ["src"]
11182

112-
[tool.ruff.per-file-ignores]
113-
"docs/conf.py" = ["INP001"]
83+
[tool.ruff.lint]
84+
select = [
85+
"B", # flake8-bugbear
86+
"D", # pydocstyle
87+
"E", # pycodestyle error
88+
"F", # Pyflakes
89+
"I", # isort
90+
"RUF100", # Unused noqa directive
91+
"S", # flake8-bandit
92+
"SIM", # flake8-simplify
93+
"UP", # pyupgrade
94+
"W", # pycodestyle warning
95+
]
96+
97+
[tool.ruff.lint.per-file-ignores]
11498
"test/*" = ["S101"]
11599

100+
[tool.ruff.lint.pydocstyle]
101+
convention = "google"
102+
116103
[tool.setuptools.dynamic]
117104
dependencies = {file = ["requirements.txt"]}
118105

requirements/lint.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
# Requirements for lint.
2-
black
3-
isort
42
mypy
53
ruff
64
toml-sort

src/ss_python/settings.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ class GlobalSettings(BaseSettings):
1616
class Settings(BaseSettings):
1717
"""Project specific settings."""
1818

19-
# NOTE(huxuan): Pydantic cannot leverage future annotations at runtime prior to
20-
# Python 3.10, so `from __future__ import annotations` cannot be used here, and the
21-
# lint error need to be ignored unless the minimal Python version >= 3.10.
22-
# Reference: https://github.com/pydantic/pydantic/issues/3300#issuecomment-1034007897
23-
logging_level: Optional[str] = getLevelName(logging.INFO) # noqa: FA100
19+
logging_level: Optional[str] = getLevelName(logging.INFO)
2420
"""Default logging level for the project."""
2521

2622
model_config = SettingsConfigDict(

template/.pre-commit-config.yaml.jinja

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,6 @@ repos:
4848
repo: https://github.com/pre-commit/pre-commit-hooks
4949
rev: v4.4.0
5050
- hooks:
51-
- entry: pipenv run python -m black
52-
id: black
53-
language: system
54-
name: black
55-
types:
56-
- python
57-
- entry: pipenv run python -m isort --filter-files
58-
id: isort
59-
language: system
60-
name: isort
61-
require_serial: true
62-
types_or:
63-
- cython
64-
- pyi
65-
- python
6651
- entry: make mypy
6752
id: mypy
6853
language: system
@@ -71,12 +56,22 @@ repos:
7156
require_serial: true
7257
types:
7358
- python
74-
- entry: pipenv run python -m ruff --force-exclude
59+
- entry: pipenv run python -m ruff check --force-exclude
7560
id: ruff
7661
language: system
7762
name: ruff
78-
types:
63+
require_serial: true
64+
types_or:
65+
- python
66+
- pyi
67+
- entry: pipenv run python -m ruff format --check --force-exclude
68+
id: ruff-format
69+
language: system
70+
name: ruff-format
71+
require_serial: true
72+
types_or:
7973
- python
74+
- pyi
8075
- entry: pipenv run toml-sort
8176
id: toml-sort
8277
language: system

0 commit comments

Comments
 (0)