Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ publish := uv publish --username=__token__ --keyring-provider=subprocess
test := $(run) pytest
python := $(run) python
ruff := $(run) ruff
lint := $(ruff) check --select I
lint := $(ruff) check
fmt := $(ruff) format
mypy := $(run) mypy
mkdocs := $(run) mkdocs
Expand Down
23 changes: 23 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,26 @@ explicit = true
venvPath="."
venv=".venv"
exclude=[".venv"]

[tool.ruff.lint]
select = [
# pycodestyle
"E",
# Pyflakes
"F",
# pyupgrade
"UP",
# flake8-bugbear
"B",
# flake8-simplify
"SIM",
# isort
"I",
]
ignore = [
# I think try...expect...pass reads far better.
"SIM105",
]

[tool.ruff.lint.pycodestyle]
max-line-length = 120
6 changes: 3 additions & 3 deletions src/peplum/app/data/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

##############################################################################
# Python imports.
from collections.abc import Iterator
from contextlib import contextmanager
from dataclasses import asdict, dataclass, field
from functools import lru_cache
from functools import cache
from json import dumps, loads
from pathlib import Path
from typing import Iterator

##############################################################################
# Local imports.
Expand Down Expand Up @@ -76,7 +76,7 @@ def save_configuration(configuration: Configuration) -> Configuration:


##############################################################################
@lru_cache(maxsize=None)
@cache
def load_configuration() -> Configuration:
"""Load the configuration.

Expand Down
3 changes: 2 additions & 1 deletion src/peplum/app/data/peps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
##############################################################################
# Python imports.
from collections import Counter
from collections.abc import Iterable, Iterator
from dataclasses import dataclass
from functools import total_ordering
from itertools import chain
from operator import attrgetter
from pathlib import Path
from typing import Iterable, Iterator, Literal, TypeAlias
from typing import Literal, TypeAlias

##############################################################################
# Packaging imports.
Expand Down
6 changes: 4 additions & 2 deletions src/peplum/app/providers/python_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ def commands(self) -> CommandHits:
"Also isn't related to a specific Python version"
if self.active_peps.is_filtered
else "Isn't related to a specific Python version",
f"{help_prefix} to PEPs unrelated to any specific Python version (narrows down to {version.count})",
f"{help_prefix} to PEPs unrelated to any specific Python version "
f"(narrows down to {version.count})",
ShowPythonVersion(""),
)
else:
yield CommandHit(
f"{command_prefix} {version.version}",
f"{help_prefix} to PEPs related to Python version {version.version} (narrows down to {version.count})",
f"{help_prefix} to PEPs related to Python version {version.version} "
f"(narrows down to {version.count})",
ShowPythonVersion(version.version),
)

Expand Down
6 changes: 3 additions & 3 deletions src/peplum/app/screens/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def load_pep_data(self) -> None:
)
)
)
except IOError as error:
except OSError as error:
self.notify(str(error), title="Error loading PEP data", severity="error")

@work(thread=True)
Expand All @@ -248,7 +248,7 @@ async def download_pep_data(self) -> None:
# Store the raw data.
try:
pep_data().write_text(dumps(raw_data, indent=4), encoding="utf-8")
except IOError as error:
except OSError as error:
self.notify(str(error), title="Error saving PEP data", severity="error")
return
# Now kick off loading the raw data.
Expand Down Expand Up @@ -529,7 +529,7 @@ def _save_notes(self) -> None:
"""Save the notes."""
try:
self.notes.save()
except IOError as error:
except OSError as error:
self.notify(
str(error), title="Unable to save notes", severity="error", timeout=8
)
Expand Down
8 changes: 4 additions & 4 deletions src/peplum/app/screens/pep_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ async def _download_text(self) -> None:
if self._cache_name.exists():
try:
pep_source = self._cache_name.read_text(encoding="utf-8")
except IOError:
except OSError:
pass

if not pep_source:
Expand All @@ -125,7 +125,7 @@ async def _download_text(self) -> None:
pep_source := await API().get_pep(self._pep.number),
encoding="utf-8",
)
except IOError:
except OSError:
pass
except API.RequestError as error:
pep_source = "Error downloading PEP source"
Expand All @@ -151,7 +151,7 @@ def action_refresh(self) -> None:
"""Refresh the PEP source."""
try:
self._cache_name.unlink(missing_ok=True)
except IOError:
except OSError:
pass
self._download_text()

Expand All @@ -178,7 +178,7 @@ async def action_save(self) -> None:
return
try:
target.write_text(self.query_one(TextArea).text, encoding="utf-8")
except IOError as error:
except OSError as error:
self.notify(str(error), title="Save Failed", severity="error")
return
self.notify(str(target), title="Saved")
Expand Down
6 changes: 3 additions & 3 deletions src/peplum/app/widgets/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

##############################################################################
# Python imports.
from typing import Callable
from collections.abc import Callable

##############################################################################
# Rich imports.
Expand Down Expand Up @@ -100,7 +100,7 @@ def __init__(self, peps: PEPs, key: str, key_colour: str | None) -> None:
"""
super().__init__(
self.count_prompt(f"All [{(key_colour or 'dim')}]\\[{key}][/]", len(peps)),
id=f"_all_peps",
id="_all_peps",
)

@property
Expand Down Expand Up @@ -168,7 +168,7 @@ def __init__(self, version: PythonVersionCount) -> None:
self._version = version
"""The Python version to show."""
super().__init__(
self.count_prompt(version.version or f"[dim i]None[/]", version.count),
self.count_prompt(version.version or "[dim i]None[/]", version.count),
id=f"_python_version_{version.version}",
)

Expand Down
3 changes: 2 additions & 1 deletion src/peplum/app/widgets/pep_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

##############################################################################
# Python imports.
from collections.abc import Sequence
from datetime import date, datetime
from functools import singledispatchmethod
from typing import Final, Sequence
from typing import Final
from webbrowser import open as visit_url

##############################################################################
Expand Down
10 changes: 8 additions & 2 deletions tests/unit/test_peps.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@
"topic": "",
"created": "30-Mar-2014",
"python_version": "3.13",
"post_history": "30-Mar-2014, 15-Aug-2014, 16-Aug-2014, 07-Jun-2016, 01-Sep-2016, 13-Apr-2021, 03-Nov-2021, 27-Dec-2023",
"post_history": (
"30-Mar-2014, 15-Aug-2014, 16-Aug-2014, 07-Jun-2016, 01-Sep-2016, 13-Apr-2021, 03-Nov-2021, 27-Dec-2023"
),
"resolution": None,
"requires": None,
"replaces": None,
Expand All @@ -99,7 +101,11 @@
"topic": "packaging",
"created": "15-Aug-2019",
"python_version": None,
"post_history": "`15-Aug-2019 <https://discuss.python.org/t/2154>`__, `17-Dec-2021 <https://discuss.python.org/t/12622>`__, `10-May-2024 <https://discuss.python.org/t/53020>`__,",
"post_history": (
"`15-Aug-2019 <https://discuss.python.org/t/2154>`__, "
"`17-Dec-2021 <https://discuss.python.org/t/12622>`__, "
"`10-May-2024 <https://discuss.python.org/t/53020>`__,"
),
"resolution": "https://discuss.python.org/t/53020/106",
"requires": None,
"replaces": None,
Expand Down