Skip to content

Commit f46c52d

Browse files
authored
Merge pull request #641 from ably/ruff
Switch from flake8 to ruff for linting
2 parents 101e2b5 + 215acb6 commit f46c52d

File tree

6 files changed

+50
-70
lines changed

6 files changed

+50
-70
lines changed

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ jobs:
3333

3434
- name: Install dependencies
3535
run: uv sync --extra dev
36-
- name: Lint with flake8
37-
run: uv run flake8
36+
- name: Lint with ruff
37+
run: uv run ruff check

ably/util/crypto.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def get_default_params(params=None):
153153
if not key:
154154
raise ValueError("Crypto.get_default_params: a key is required")
155155

156-
if type(key) == str:
156+
if isinstance(key, str):
157157
key = base64.b64decode(key)
158158

159159
cipher_params = CipherParams(algorithm=algorithm, secret_key=key, iv=iv, mode=mode)

pyproject.toml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ vcdiff = ["vcdiff-decoder>=0.1.0,<0.2.0"]
4343
dev = [
4444
"pytest>=7.1,<8.0",
4545
"mock>=4.0.3,<5.0.0",
46-
"pep8-naming>=0.4.1,<0.5.0",
4746
"pytest-cov>=2.4,<3.0",
48-
"flake8>=3.9.2,<4.0.0",
47+
"ruff>=0.14.0,<1.0.0",
4948
"pytest-xdist>=1.15,<2.0",
5049
"respx>=0.20.0,<0.21.0; python_version=='3.7'",
5150
"respx>=0.22.0,<0.23.0; python_version>='3.8'",
@@ -79,3 +78,20 @@ timeout = 30
7978
name = "experimental"
8079
url = "https://test.pypi.org/simple/"
8180
explicit = true
81+
82+
[tool.ruff]
83+
line-length = 115
84+
extend-exclude = [
85+
"ably/sync",
86+
"test/ably/sync",
87+
]
88+
89+
[tool.ruff.lint]
90+
# Enable Pyflakes (F), pycodestyle (E, W), and pep8-naming (N)
91+
select = ["E", "W", "F", "N"]
92+
ignore = [
93+
"N818", # exception name should end in 'Error'
94+
]
95+
96+
[tool.ruff.lint.per-file-ignores]
97+
"__init__.py" = ["F401"] # imported but unused

setup.cfg

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
[coverage:run]
22
branch=True
33

4-
[flake8]
5-
max-line-length = 115
6-
ignore = W503, W504, N818
7-
per-file-ignores =
8-
# imported but unused
9-
__init__.py: F401
10-
# Exclude virtual environment check
11-
exclude = .venv,venv,env,.env,.git,__pycache__,.pytest_cache,build,dist,*.egg-info,ably/sync,test/ably/sync
12-
134
[tool:pytest]
145
#log_level = DEBUG

test/ably/rest/restchannelpublish_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ async def check_data():
423423
async def check_history():
424424
history = await channel.history()
425425
message = history.items[0]
426-
return message.data == expected_value and type(message.data) == type_mapping[expected_type]
426+
return message.data == expected_value and isinstance(message.data, type_mapping[expected_type])
427427

428428
await assert_waiter(check_history)
429429

uv.lock

Lines changed: 28 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)