Skip to content

Commit

Permalink
Bump pre-commit hook versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
lemon24 committed Mar 10, 2024
1 parent b98136f commit d5a31b2
Show file tree
Hide file tree
Showing 45 changed files with 52 additions and 66 deletions.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ ignore =
W503
# string formatting opinion
B907
# multiple statements on one line, handled by black
E704
per-file-ignores =
# __init__ modules export names
**/__init__.py: F401
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ repos:
- id: isort

- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
rev: v3.15.1
hooks:
- id: pyupgrade
args: ["--py310-plus"]

- repo: https://github.com/python/black
rev: 23.11.0
rev: 24.2.0
hooks:
- id: black
args: ["-S"]

- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies: [flake8-bugbear]
Expand Down
1 change: 1 addition & 0 deletions examples/parser_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
Has your password been pwned? Or, how I almost failed to search a 37 GB text file in under 1 millisecond (in Python)
""" # docstring-end

import asyncio
import io
import httpx
Expand Down
1 change: 1 addition & 0 deletions examples/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"""

import logging
import os
import sys
Expand Down
1 change: 1 addition & 0 deletions scripts/debug_storage_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
Initially made for #175 and #178.
"""

import json
import re
import sys
Expand Down
8 changes: 5 additions & 3 deletions src/reader/_app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,11 @@ def feeds():
(
feed,
list(reader.get_tag_keys(feed)),
reader.get_entry_counts(feed=feed)
if with_counts or sort in FEED_SORT_FANCY
else None,
(
reader.get_entry_counts(feed=feed)
if with_counts or sort in FEED_SORT_FANCY
else None
),
)
for feed in feeds
)
Expand Down
1 change: 1 addition & 0 deletions src/reader/_app/api_thing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
See scripts/jscontrols.py for a minimal usage example.
"""

from urllib.parse import urljoin
from urllib.parse import urlparse

Expand Down
1 change: 1 addition & 0 deletions src/reader/_app/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
flask run -h 0.0.0.0 -p 8000
"""

import os

import yaml
Expand Down
1 change: 1 addition & 0 deletions src/reader/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
https://github.com/lemon24/reader/issues/177
"""

import copy
from collections.abc import Mapping
from dataclasses import dataclass
Expand Down
1 change: 1 addition & 0 deletions src/reader/_hash_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
Implemented for https://github.com/lemon24/reader/issues/179
"""

from __future__ import annotations

import dataclasses
Expand Down
6 changes: 0 additions & 6 deletions src/reader/_parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ class RetrieveResult(_namedtuple_compat, Generic[T_co]):


class RetrieverType(Protocol[T_co]): # pragma: no cover

"""A callable that knows how to retrieve a feed."""

#: Allow :class:`Parser` to :meth:`~io.BufferedIOBase.read`
Expand Down Expand Up @@ -234,7 +233,6 @@ def validate_url(self, url: str) -> None:

@runtime_checkable
class FeedForUpdateRetrieverType(RetrieverType[T_co], Protocol): # pragma: no cover

"""A :class:`RetrieverType` that can change update-relevant information."""

def process_feed_for_update(self, feed: FeedForUpdate) -> FeedForUpdate:
Expand All @@ -256,7 +254,6 @@ def process_feed_for_update(self, feed: FeedForUpdate) -> FeedForUpdate:


class ParserType(Protocol[T_cv]): # pragma: no cover

"""A callable that knows how to parse a retrieved feed."""

def __call__(
Expand All @@ -280,7 +277,6 @@ def __call__(

@runtime_checkable
class HTTPAcceptParserType(ParserType[T_cv], Protocol): # pragma: no cover

"""A :class:`ParserType` that knows what content it can handle."""

@property
Expand All @@ -293,7 +289,6 @@ def http_accept(self) -> str:

@runtime_checkable
class EntryPairsParserType(ParserType[T_cv], Protocol): # pragma: no cover

"""A :class:`ParserType` that can modify entry data before being stored."""

def process_entry_pairs(
Expand All @@ -314,7 +309,6 @@ def process_entry_pairs(


class FeedArgument(Protocol): # pragma: no cover

"""Any :class:`~reader._types.FeedForUpdate`-like object."""

@property
Expand Down
1 change: 1 addition & 0 deletions src/reader/_parser/_http_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
HTTP utilities. Contains no business logic.
"""

from collections.abc import Iterable

import werkzeug.http
Expand Down
1 change: 0 additions & 1 deletion src/reader/_parser/_lazy.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@


class Parser:

"""Retrieve and parse feeds by delegating to
:class:`retrievers <RetrieverType>` and :class:`parsers <ParserType>`.
Expand Down
1 change: 1 addition & 0 deletions src/reader/_parser/_url_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
In this context, bare paths are considered equivalent to file:// URIs.
"""

from __future__ import annotations

import os.path
Expand Down
1 change: 0 additions & 1 deletion src/reader/_parser/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

@dataclass(frozen=True)
class FileRetriever:

"""Bare path and file:// URI parser.
Allows restricting file-system access to a single directory;
Expand Down
1 change: 0 additions & 1 deletion src/reader/_parser/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

@dataclass(frozen=True)
class HTTPRetriever:

"""http(s):// retriever that uses Requests.
Roughly following feedparser's implementation[*]_,
Expand Down
1 change: 0 additions & 1 deletion src/reader/_parser/jsonfeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@


class JSONFeedParser:

"""https://jsonfeed.org/version/1.1"""

http_accept = 'application/feed+json,application/json;q=0.9'
Expand Down
3 changes: 1 addition & 2 deletions src/reader/_parser/requests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Requests utilities. Contains no business logic.
"""

from __future__ import annotations

from collections.abc import Iterator
Expand Down Expand Up @@ -30,7 +31,6 @@


class RequestHook(Protocol):

"""Hook to modify a :class:`~requests.Request` before it is sent."""

def __call__(
Expand Down Expand Up @@ -92,7 +92,6 @@ def __call__(

@dataclass
class SessionFactory:

"""Manage the lifetime of a session.
To get new session, :meth:`call<__call__>` the factory directly.
Expand Down
2 changes: 0 additions & 2 deletions src/reader/_parser/requests/_lazy.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@


class TimeoutHTTPAdapter(requests.adapters.HTTPAdapter):

"""Add a default timeout to requests.
https://requests.readthedocs.io/en/master/user/advanced/#timeouts
Expand All @@ -45,7 +44,6 @@ def send(self, *args: Any, **kwargs: Any) -> Any:

@dataclass
class SessionWrapper:

"""Minimal wrapper over a :class:`requests.Session`.
Only provides a limited :meth:`get` method.
Expand Down
2 changes: 1 addition & 1 deletion src/reader/_plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
the contents of the actual plugins is not.
"""

import functools
from contextlib import contextmanager
from pkgutil import resolve_name
Expand All @@ -21,7 +22,6 @@ def raise_exception(message, cause):


class Loader:

"""Plugin loader.
Allows customizing plugin import/initialization failure behavior.
Expand Down
1 change: 1 addition & 0 deletions src/reader/_plugins/cli_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
python -m reader ...
"""

import io
import shlex
import sys
Expand Down
1 change: 1 addition & 0 deletions src/reader/_plugins/enclosure_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
Became a plugin in https://github.com/lemon24/reader/issues/52.
"""

import tempfile
from urllib.parse import urlparse

Expand Down
1 change: 1 addition & 0 deletions src/reader/_plugins/preview_feed_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
Implemented for https://github.com/lemon24/reader/issues/150.
"""

import traceback
import urllib.parse
import warnings
Expand Down
1 change: 1 addition & 0 deletions src/reader/_plugins/share.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
python -m reader serve
"""

from urllib.parse import quote
from urllib.parse import urlparse

Expand Down
1 change: 1 addition & 0 deletions src/reader/_plugins/sqlite_releases.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
python -m reader ...
"""

import warnings
from datetime import datetime
from datetime import timezone
Expand Down
1 change: 1 addition & 0 deletions src/reader/_plugins/timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
pip install reader[unstable-plugins]
"""

import inspect
from collections.abc import Collection
from collections.abc import Iterable
Expand Down
14 changes: 8 additions & 6 deletions src/reader/_storage/_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,12 +642,14 @@ def entry_update_intent_to_dict(intent: EntryUpdateIntent) -> dict[str, Any]:
updated=adapt_datetime(entry.updated) if entry.updated else None,
published=adapt_datetime(entry.published) if entry.published else None,
last_updated=adapt_datetime(intent.last_updated),
first_updated=adapt_datetime(intent.first_updated)
if intent.first_updated
else None,
first_updated_epoch=adapt_datetime(intent.first_updated_epoch)
if intent.first_updated_epoch
else None,
first_updated=(
adapt_datetime(intent.first_updated) if intent.first_updated else None
),
first_updated_epoch=(
adapt_datetime(intent.first_updated_epoch)
if intent.first_updated_epoch
else None
),
recent_sort=adapt_datetime(intent.recent_sort) if intent.recent_sort else None,
data_hash=entry.hash,
data_hash_changed=context.pop('hash_changed'),
Expand Down
6 changes: 3 additions & 3 deletions src/reader/_storage/_feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ def _update_feed_full(self, intent: FeedUpdateIntent) -> None:
context.update(
feed._asdict(),
updated=adapt_datetime(feed.updated) if feed.updated else None,
last_updated=adapt_datetime(intent.last_updated)
if intent.last_updated
else None,
last_updated=(
adapt_datetime(intent.last_updated) if intent.last_updated else None
),
data_hash=feed.hash,
)

Expand Down
1 change: 1 addition & 0 deletions src/reader/_storage/_html_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
HTML utilities. Contains no business logic.
"""

from __future__ import annotations

import warnings
Expand Down
1 change: 0 additions & 1 deletion src/reader/_storage/_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@


class Search:

"""Search provider tightly coupled to the SQLite storage.
Originally done in #122. Updated to use the change tracking API in #323.
Expand Down
1 change: 1 addition & 0 deletions src/reader/_storage/_sql_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
How to implement: INSERT/UPDATE/DELETE, subqueries, UNION/...
"""

from __future__ import annotations

import functools
Expand Down
3 changes: 1 addition & 2 deletions src/reader/_storage/_sqlite_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
sqlite3 utilities. Contains no business logic.
"""

from __future__ import annotations

import functools
Expand Down Expand Up @@ -400,7 +401,6 @@ class UsageError(DBError):


class LocalConnectionFactory:

"""Maintain a set of connections to the same database, one per thread.
connect() on object creation in the creating thread,
Expand Down Expand Up @@ -700,7 +700,6 @@ def _log(self, data):

@no_type_check
class DebugConnection(sqlite3.Connection):

"""sqlite3 connection subclass for debugging stuff.
>>> debug = logging.getLogger('whatever').debug
Expand Down
Loading

0 comments on commit d5a31b2

Please sign in to comment.