Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
yagebu committed Oct 25, 2023
1 parent 433b562 commit f0df868
Show file tree
Hide file tree
Showing 65 changed files with 98 additions and 36 deletions.
1 change: 1 addition & 0 deletions _build_backend.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Build backend that also compiles translations and frontend."""

# pylint: disable=wildcard-import,function-redefined,unused-wildcard-import

from __future__ import annotations
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""fava wsgi application"""

from __future__ import annotations

from fava.application import create_app
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""fava wsgi application"""

from __future__ import annotations

from fava.application import create_app
Expand Down
1 change: 1 addition & 0 deletions docs/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
sphinx-apidoc is not customizeable enough to do this.
"""

from __future__ import annotations

import pkgutil
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/AutocompleteInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@
ul {
position: absolute;
z-index: var(--z-index-autocomplete);
overflow-x: hidden;
overflow-y: auto;
overflow: hidden auto;
background-color: var(--background);
border: 1px solid var(--border-darker);
box-shadow: 0 3px 3px var(--border);
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ filterwarnings = "ignore:.*locked_cached_property.*deprecated:DeprecationWarning

[tool.ruff]
target-version = "py38"
preview = true
line-length = 79
extend-select = [
"ALL",
Expand All @@ -130,15 +131,18 @@ extend-ignore = [
"ANN101", # allow `self` to be untyped
"ANN401", # allow `typing.Any`
"C901", # ignore mccabe complecity for now
"CPY", # no copyright notices in all files
"D102", # allow undocumented methods
"D105", # allow magic methods to be undocumented
"D107", # allow __init__ to be undocumented - the class should be.
"DTZ", # allow naive dates (for now)
"E203", # black
"EM101", # allow long strings as error messages
"EM102", # allow f-strings as error messages
"PD", # pandas-related, has false-positives
"PERF203", # allow try-except in loop; zero-cost since Python 3.11
"PLR2004", # allow magic constants in comparisons
"PLR6301", # allow methods that do not use self
"S603", # This is a bit over-zelous on subprocess.run
"TRY003", # allow long string constants as error messages
]
Expand Down
1 change: 1 addition & 0 deletions src/fava/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Fava - A web interface for Beancount."""

from __future__ import annotations

from contextlib import suppress
Expand Down
11 changes: 6 additions & 5 deletions src/fava/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
app.run('localhost', 5000)
"""

from __future__ import annotations

import logging
Expand All @@ -26,7 +27,7 @@
from urllib.parse import urlparse
from urllib.parse import urlunparse

import markdown2 # type: ignore[import]
import markdown2 # type: ignore[import-untyped]
from beancount import __version__ as beancount_version
from beancount.utils.text_utils import replace_numbers
from flask import abort
Expand All @@ -38,7 +39,7 @@
from flask import request
from flask import send_file
from flask import url_for as flask_url_for
from flask_babel import Babel # type: ignore[import]
from flask_babel import Babel # type: ignore[import-untyped]
from flask_babel import get_translations
from markupsafe import Markup
from werkzeug.utils import secure_filename
Expand Down Expand Up @@ -130,9 +131,9 @@ def _inject_filters(endpoint: str, values: dict[str, str]) -> None:
and g.beancount_file_slug is not None
):
values["bfile"] = g.beancount_file_slug
if endpoint in ["static", "index"]:
if endpoint in {"static", "index"}:
return
for name in ["conversion", "interval", "account", "filter", "time"]:
for name in ("conversion", "interval", "account", "filter", "time"):
if name not in values:
val = request.args.get(name)
if val is not None:
Expand Down Expand Up @@ -188,7 +189,7 @@ def _setup_filters(

@fava_app.before_request
def _perform_global_filters() -> None:
if request.endpoint in ("json_api.get_changed", "json_api.get_errors"):
if request.endpoint in {"json_api.get_changed", "json_api.get_errors"}:
return
ledger = getattr(g, "ledger", None)
if ledger:
Expand Down
1 change: 1 addition & 0 deletions src/fava/beans/abc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Abstract base classes for Beancount types."""

from __future__ import annotations

from abc import ABC
Expand Down
1 change: 1 addition & 0 deletions src/fava/beans/account.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Account name helpers."""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 0 additions & 1 deletion src/fava/beans/create.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Helpers to create entries."""


from __future__ import annotations

from decimal import Decimal
Expand Down
1 change: 1 addition & 0 deletions src/fava/beans/flags.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Beancount entry flags."""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions src/fava/beans/funcs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Various functions to deal with Beancount data."""

from __future__ import annotations

from typing import Any
Expand Down
1 change: 1 addition & 0 deletions src/fava/beans/helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Helpers for Beancount entries."""

from __future__ import annotations

from typing import Any
Expand Down
1 change: 1 addition & 0 deletions src/fava/beans/load.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Load Beancount files and strings."""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions src/fava/beans/prices.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Price helpers."""

from __future__ import annotations

import datetime
Expand Down
8 changes: 5 additions & 3 deletions src/fava/beans/str.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
"""Convert Beancount types to string."""

from __future__ import annotations

from decimal import Decimal
from functools import singledispatch

from beancount.core.position import CostSpec
from beancount.parser.printer import format_entry # type: ignore[import]
from beancount.parser.printer import ( # type: ignore[import-untyped]
format_entry,
)

from fava.beans.abc import Amount
from fava.beans.abc import Cost
Expand Down Expand Up @@ -51,8 +54,7 @@ def _(cost: CostSpec) -> str:
if isinstance(cost.number_per, Decimal):
amountlist.append(f"{cost.number_per}")
if isinstance(cost.number_total, Decimal):
amountlist.append("#")
amountlist.append(f"{cost.number_total}")
amountlist.extend(("#", f"{cost.number_total}"))
if cost.currency:
amountlist.append(cost.currency)
strs.append(" ".join(amountlist))
Expand Down
1 change: 1 addition & 0 deletions src/fava/beans/types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Typing helpers."""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions src/fava/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The command-line interface for Fava."""

from __future__ import annotations

import errno
Expand Down
1 change: 1 addition & 0 deletions src/fava/context.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Specify types for the flask application context."""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions src/fava/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module provides the data required by Fava's reports."""

from __future__ import annotations

from datetime import date
Expand Down
1 change: 1 addition & 0 deletions src/fava/core/accounts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Account close date and metadata."""

from __future__ import annotations

import datetime
Expand Down
1 change: 1 addition & 0 deletions src/fava/core/attributes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Attributes for auto-completion."""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions src/fava/core/budgets.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Parsing and computing budgets."""

from __future__ import annotations

from collections import Counter
Expand Down
1 change: 1 addition & 0 deletions src/fava/core/charts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Provide data suitable for Fava's charts."""

from __future__ import annotations

from collections import defaultdict
Expand Down
1 change: 1 addition & 0 deletions src/fava/core/commodities.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Attributes for auto-completion."""

from __future__ import annotations

from contextlib import suppress
Expand Down
1 change: 1 addition & 0 deletions src/fava/core/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
All functions in this module will be automatically added as template filters.
"""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions src/fava/core/documents.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Document path related helpers."""

from __future__ import annotations

from os import altsep
Expand Down
7 changes: 2 additions & 5 deletions src/fava/core/extensions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Fava extensions."""

from __future__ import annotations

from dataclasses import dataclass
Expand Down Expand Up @@ -47,11 +48,7 @@ def load_file(self) -> None:

for cls in all_extensions:
module = cls.__module__
ext_config = (
_extension_entries[module]
if (module in _extension_entries)
else None
)
ext_config = _extension_entries.get(module, None)
if cls not in self._loaded_extensions:
self._loaded_extensions.add(cls)
ext = cls(self.ledger, ext_config)
Expand Down
1 change: 1 addition & 0 deletions src/fava/core/fava_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
parsing the options.
"""

from __future__ import annotations

import re
Expand Down
1 change: 1 addition & 0 deletions src/fava/core/file.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Reading/writing Beancount files."""

from __future__ import annotations

import re
Expand Down
7 changes: 4 additions & 3 deletions src/fava/core/filters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Entry filters."""

from __future__ import annotations

import re
Expand All @@ -9,9 +10,9 @@
from typing import Iterable
from typing import TYPE_CHECKING

import ply.yacc # type: ignore[import]
import ply.yacc # type: ignore[import-untyped]
from beancount.core import account
from beancount.ops.summarize import clamp_opt # type: ignore[import]
from beancount.ops.summarize import clamp_opt # type: ignore[import-untyped]

from fava.beans.account import get_entry_accounts
from fava.helpers import FavaAPIError
Expand Down Expand Up @@ -86,7 +87,7 @@ def ANY(self, token: str, _: str) -> tuple[str, str]: # noqa: N802
return token, token

def STRING(self, token: str, value: str) -> tuple[str, str]: # noqa: N802
if value[0] in ['"', "'"]:
if value[0] in {'"', "'"}:
return token, value[1:-1]
return token, value

Expand Down
1 change: 1 addition & 0 deletions src/fava/core/group_entries.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Entries grouped by type."""

from __future__ import annotations

from collections import defaultdict
Expand Down
3 changes: 2 additions & 1 deletion src/fava/core/ingest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Ingest helper functions."""

from __future__ import annotations

import datetime
Expand All @@ -12,7 +13,7 @@
from typing import Any
from typing import TYPE_CHECKING

from beancount.ingest import cache # type: ignore[import]
from beancount.ingest import cache # type: ignore[import-untyped]
from beancount.ingest import extract
from beancount.ingest import identify

Expand Down
1 change: 1 addition & 0 deletions src/fava/core/inventory.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Alternative implementation of Beancount's Inventory."""

from __future__ import annotations

from decimal import Decimal
Expand Down
1 change: 1 addition & 0 deletions src/fava/core/misc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Some miscellaneous reports."""

from __future__ import annotations

import datetime
Expand Down
1 change: 1 addition & 0 deletions src/fava/core/module_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Base class for the "modules" of FavaLedger."""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions src/fava/core/number.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Formatting numbers."""

from __future__ import annotations

import copy
Expand Down
3 changes: 2 additions & 1 deletion src/fava/core/query_shell.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""For using the Beancount shell from Fava."""

from __future__ import annotations

import contextlib
Expand All @@ -12,7 +13,7 @@
from beancount.query.query_compile import CompilationError
from beancount.query.query_parser import ParseError
from beancount.query.query_parser import RunCustom
from beancount.query.shell import BQLShell # type: ignore[import]
from beancount.query.shell import BQLShell # type: ignore[import-untyped]
from beancount.utils import pager # type: ignore[attr-defined]

from fava.beans.funcs import execute_query
Expand Down
1 change: 1 addition & 0 deletions src/fava/core/tree.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Account balance trees."""

from __future__ import annotations

from collections import defaultdict
Expand Down
1 change: 1 addition & 0 deletions src/fava/core/watcher.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A simple file and folder watcher."""

from __future__ import annotations

from os import walk
Expand Down
Loading

0 comments on commit f0df868

Please sign in to comment.