Skip to content

Commit

Permalink
swap black to ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
xavdid-stripe committed May 10, 2024
1 parent 287c85d commit 9b43579
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 29 deletions.
4 changes: 3 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
# length, but can go over in some cases.
# W503 goes against PEP8 rules. It's disabled by default, but must be disabled
# explicitly when using `ignore`.
ignore = E501, W503
# E704 is disabled in the default configuration, but by specifying `ignore`, we wipe that out.
# ruff formatting creates code that violates it, so we have to disable it manually
ignore = E501, W503, E704
per-file-ignores =
*/__init__.py: IMP100, E402, F401
# we test various import patterns
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ Run the linter with:
make lint
```
The library uses [Black][black] for code formatting. Code must be formatted
The library uses [Ruff][ruff] for code formatting. Code must be formatted
with Black before PRs are submitted, otherwise CI will fail. Run the formatter
with:
Expand All @@ -378,7 +378,7 @@ make fmt
```
[api-keys]: https://dashboard.stripe.com/account/apikeys
[black]: https://github.com/ambv/black
[ruff]: https://github.com/astral-sh/ruff
[connect]: https://stripe.com/connect
[poetry]: https://github.com/sdispater/poetry
[stripe-mock]: https://github.com/stripe/stripe-mock
Expand Down
33 changes: 9 additions & 24 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,33 +1,18 @@
[tool.black]
[tool.ruff]
# same as our black config
line-length = 79
target-version = [
"py35",
"py36",
"py37",
"py38",
"py39",
"py310",
# "py311", # black 21.12b0 doesn't
# "py312", # support these targets
]
exclude = '''
/(
\.eggs/
| \.git/
| \.tox/
| \.venv/
| _build/
| build/
| dist/
| venv/
)
'''
extend-exclude = ["build"]

[tool.ruff.format]
# currently the default value, but opt-out in the future
docstring-code-format = false

[tool.pyright]
include = [
"stripe",
"tests/test_generated_examples.py",
"tests/test_exports.py",
"tests/test_http_client.py"
"tests/test_http_client.py",
]
exclude = ["build", "**/__pycache__"]
reportMissingTypeArgument = true
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ tox == 4.5.0
#Virtualenv 20.22.0 dropped support for all Python versions smaller or equal to Python 3.6.
virtualenv<20.22.0
pyright == 1.1.336
black == 22.8.0
ruff == 0.4.4
flake8
mypy == 1.7.0

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ skip_install = true
commands =
pyright: pyright {posargs}
lint: python -m flake8 --show-source stripe tests setup.py
fmt: black . {posargs}
fmt: ruff format . {posargs}
mypy: mypy {posargs}
deps =
-r requirements.txt
Expand Down

0 comments on commit 9b43579

Please sign in to comment.