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
35 changes: 35 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Lint and Format

on:
pull_request:
paths:
- "pyproject.toml"
- "src/**"
- ".github/workflows/ruff.yml"
push:
paths:
- "pyproject.toml"
- "src/**"
- ".github/workflows/ruff.yml"
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.14"
- run: pip install ruff
- name: Lint (ruff check)
run: ruff check
- name: Format (ruff format --check)
run: ruff format --check
26 changes: 26 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,29 @@ build-backend = "setuptools.build_meta"

[tool.setuptools.packages.find]
where = ["src"]

# Development purposes only
[project.optional-dependencies]
dev = ["ruff >= 0.15.5"]

[tool.ruff]
target-version = "py311"

[tool.ruff.lint]
select = [
"B", # flake8-bugbear
"E", # pycodestyle Error
"F", # Pyflakes
"I", # isort
"PL", # Pylint
"SIM", # flake8-simplify
"TC", # flake8-type-checking
"W" # pycodestyle Warning
]
ignore = [
"TC001" # typing-only-first-party-import
]

[tool.ruff.format]
quote-style = "double"
indent-style = "space"
1 change: 0 additions & 1 deletion src/bookmeterjson/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import yaml


VALID_CATEGORIES = {"read", "reading", "stacked", "wish"}


Expand Down
5 changes: 2 additions & 3 deletions src/bookmeterjson/scraper.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import contextlib
import json
import math
import time
Expand Down Expand Up @@ -84,10 +85,8 @@ def parse_book_entry(book_el, category: str) -> BookEntry:
# User-overridable page count from detail__page
page_el = book_el.select_one(".detail__page")
if page_el and page_el.text.strip():
try:
with contextlib.suppress(ValueError):
entry.detail_pages = int(page_el.text.strip())
except ValueError:
pass

# Edit modal with review and bookcases
edit_div = book_el.select_one(".detail__edit .js-modal-button")
Expand Down