Skip to content

Commit a7f70c0

Browse files
authored
🔀 Merge pull request #197 from davep/tighten-linting
Tighten up the linting rules
2 parents 8be051f + 5f7d4ad commit a7f70c0

File tree

13 files changed

+54
-23
lines changed

13 files changed

+54
-23
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ publish := uv publish --username=__token__ --keyring-provider=subprocess
88
test := $(run) pytest
99
python := $(run) python
1010
ruff := $(run) ruff
11-
lint := $(ruff) check --select I
11+
lint := $(ruff) check
1212
fmt := $(ruff) format
1313
mypy := $(run) mypy
1414
spell := $(run) codespell

pyproject.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,26 @@ asyncio_default_fixture_loop_scope = "function"
8989
venvPath="."
9090
venv=".venv"
9191
exclude=[".venv"]
92+
93+
[tool.ruff.lint]
94+
select = [
95+
# pycodestyle
96+
"E",
97+
# Pyflakes
98+
"F",
99+
# pyupgrade
100+
"UP",
101+
# flake8-bugbear
102+
"B",
103+
# flake8-simplify
104+
"SIM",
105+
# isort
106+
"I",
107+
]
108+
ignore = [
109+
# I think try...expect...pass reads far better.
110+
"SIM105",
111+
]
112+
113+
[tool.ruff.lint.pycodestyle]
114+
max-line-length = 120

src/braindrop/app/braindrop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def api_token(self) -> str | None:
9797
return self.environmental_token() or token_file().read_text(
9898
encoding="utf-8"
9999
)
100-
except IOError:
100+
except OSError:
101101
pass
102102
return None
103103

src/braindrop/app/data/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
##############################################################################
44
# Python imports.
5+
from collections.abc import Iterator
56
from contextlib import contextmanager
67
from dataclasses import asdict, dataclass, field
7-
from functools import lru_cache
8+
from functools import cache
89
from json import dumps, loads
910
from pathlib import Path
10-
from typing import Iterator
1111

1212
##############################################################################
1313
# Local imports.
@@ -63,7 +63,7 @@ def save_configuration(configuration: Configuration) -> Configuration:
6363

6464

6565
##############################################################################
66-
@lru_cache(maxsize=None)
66+
@cache
6767
def load_configuration() -> Configuration:
6868
"""Load the configuration.
6969

src/braindrop/app/data/local.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
##############################################################################
44
# Python imports.
5+
from collections.abc import Callable, Iterable, Iterator
56
from datetime import datetime
67
from json import dumps, loads
78
from pathlib import Path
8-
from typing import Any, Callable, Final, Iterable, Iterator, Self
9+
from typing import Any, Final, Self
910

1011
##############################################################################
1112
# pytz imports.

src/braindrop/app/data/raindrops.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66

77
##############################################################################
88
# Python imports.
9+
from collections import Counter
10+
from collections.abc import Callable, Iterable, Iterator
911
from dataclasses import dataclass
1012
from functools import total_ordering
11-
from typing import Callable, Counter, Iterable, Iterator, Self, TypeAlias
13+
from typing import Self
1214

1315
##############################################################################
1416
# Local imports.
@@ -81,7 +83,7 @@ def __eq__(self, value: object, /) -> bool:
8183

8284

8385
##############################################################################
84-
Filters: TypeAlias = tuple["Filter", ...]
86+
type Filters = tuple["Filter", ...]
8587
"""The type of a collection of filters."""
8688

8789

src/braindrop/app/screens/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
##############################################################################
44
# Python imports.
5-
from typing import Callable
5+
from collections.abc import Callable
66
from webbrowser import open as open_url
77

88
##############################################################################

src/braindrop/app/screens/raindrop_input.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
##############################################################################
44
# Python imports.
5-
from typing import Iterator
5+
from collections.abc import Iterator
66

77
##############################################################################
88
# httpx imports.

src/braindrop/app/suggestions/tags.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
##############################################################################
44
# Python imports.
5-
import re
6-
from typing import Final, Iterable, Pattern
5+
from collections.abc import Iterable
6+
from re import Pattern, compile
7+
from typing import Final
78

89
##############################################################################
910
# Textual imports.
@@ -33,7 +34,7 @@ def __init__(self, tags: Iterable[Tag | TagCount], use_cache: bool = True) -> No
3334
self._tags = [tag.tag if isinstance(tag, TagCount) else tag for tag in tags]
3435
"""The tags to take suggestions from."""
3536

36-
_SUGGESTABLE: Final[Pattern[str]] = re.compile(r".*[^,\s]$")
37+
_SUGGESTABLE: Final[Pattern[str]] = compile(r".*[^,\s]$")
3738
"""Regular expression to test if a value deserves a suggestion."""
3839

3940
async def get_suggestion(self, value: str) -> str | None:

src/braindrop/app/widgets/raindrop_details.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
##############################################################################
44
# Python imports.
5+
from collections.abc import Callable
56
from datetime import datetime
6-
from typing import Any, Callable, Final
7+
from typing import Any, Final
78

89
##############################################################################
910
# Humanize imports.

0 commit comments

Comments
 (0)