Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: linting and types #6

Merged
merged 1 commit into from
Mar 30, 2024
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
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ ignore_missing_imports = true

[tool.ruff.lint]
select = ["I"]

[tool.ruff.lint.isort]
known-first-party = ["ficamp", "tests"]
3 changes: 2 additions & 1 deletion src/ficamp/classifier/features.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from dataclasses import dataclass
from functools import lru_cache
from typing import Any

import numpy as np
from sklearn.utils import murmurhash3_32
Expand Down Expand Up @@ -46,7 +47,7 @@ def extract_city(d) -> str:
return d | {"city": "Lleida"}


def extract_payment_method(d: dict) -> str:
def extract_payment_method(d: dict) -> str | dict[str, Any]:
"Return payment method name in lowercase if found, else <UNK>"
# TODO:improve logic

Expand Down
1 change: 1 addition & 0 deletions src/ficamp/parsers/abn.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from pathlib import Path

import xlrd # type: ignore

from ficamp.datastructures import Currency, Tx
from ficamp.parsers.protocols import Parser

Expand Down
21 changes: 11 additions & 10 deletions src/ficamp/parsers/banc_sabadell.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
from decimal import Decimal
from pathlib import Path

from ficamp.parsers.protocol import Parser
from ficamp.types import Tx
from openpyxl import load_workbook

from ficamp.datastructures import Tx
from ficamp.parsers.protocols import Parser


class AccountBSabadellParser(Parser):
"""Parser for BBVA bank account extract"""
Expand All @@ -15,10 +16,10 @@ def load(self, filename: Path | None = None):
# TODO: rearrange this.

# filename = Path("../data/enero-febrero-bbva-cuenta.xlsx")
filename = os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
"data/enero-febrero-bsabadell-cuenta.xlsx",
)
# filename = os.path.join(
# os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
# "data/enero-febrero-bsabadell-cuenta.xlsx",
# )

wb = load_workbook(filename)
sheet = wb.active
Expand Down Expand Up @@ -80,10 +81,10 @@ class CreditCardBSabadellParser(Parser):
def load(self, filename: Path | None = None):
# TODO: rearrange this
# filename = Path("../data/enero-febrero-bbva-cuenta.xlsx")
filename = os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
"data/enero-febrero-bsabadell-targeta.xlsx",
)
# filename = os.path.join(
# os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
# "data/enero-febrero-bsabadell-targeta.xlsx",
# )

wb = load_workbook(filename)
sheet = wb.active
Expand Down
3 changes: 2 additions & 1 deletion src/ficamp/parsers/bbva.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
from decimal import Decimal
from pathlib import Path

from openpyxl import load_workbook

from ficamp.datastructures import Tx
from ficamp.parsers.protocols import Parser
from openpyxl import load_workbook


class AccountBBVAParser(Parser):
Expand Down
1 change: 1 addition & 0 deletions tests/test_google_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
import requests_mock

from ficamp.classifier.google_apis import (
GoogleException,
find_business_category_in_google,
Expand Down
1 change: 1 addition & 0 deletions tests/test_parsers_abn.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from decimal import Decimal

import pytest

from ficamp.parsers.abn import (
ConceptParser,
amount_parser,
Expand Down
Loading