diff --git a/.flake8 b/.flake8 index 83fdbee..94b6cb3 100644 --- a/.flake8 +++ b/.flake8 @@ -1,6 +1,3 @@ -[isort] -line_length = 79 - [flake8] max-line-length = 200 @@ -8,7 +5,7 @@ max-imports = 16 min-name-length = 1 -max-line-complexity = 24 +max-line-complexity = 25 max-string-usages = 16 @@ -44,6 +41,7 @@ ignore = WPS202, # too many module members WPS218, # too many asserts, useful for tests/ WPS226, # Found string constant over-use + WPS237, # too complex `f` string WPS301, # dotted raw import WPS305, # f-strings WPS306, # class without a base class @@ -52,5 +50,6 @@ ignore = WPS323, # '%' strings, too many false-positives (strptime, ...) WPS420, # allow 'pass' (but also 'global','local' & 'del') WPS421, # allow 'print()' function + WPS454, # wrong `raise` exception type: Exception WPS602, # @staticmethod S314, S405, # allow xml.etree.ElementTree diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 0000000..69aadbc --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,2 @@ +[settings] +line_length = 128 diff --git a/investments/data_providers/cache.py b/investments/data_providers/cache.py index 4ce6344..c183047 100644 --- a/investments/data_providers/cache.py +++ b/investments/data_providers/cache.py @@ -31,6 +31,5 @@ def get(self) -> Optional[pandas.DataFrame]: return pandas.read_pickle(self._cache_file) def put(self, df: pandas.DataFrame): - if self._cache_file is None: - return None - df.to_pickle(self._cache_file) + if self._cache_file is not None: + df.to_pickle(self._cache_file) diff --git a/investments/data_providers/cbr.py b/investments/data_providers/cbr.py index f36db1f..23b999a 100644 --- a/investments/data_providers/cbr.py +++ b/investments/data_providers/cbr.py @@ -7,7 +7,7 @@ import datetime import logging -import xml.etree.ElementTree as ET # type: ignore +import xml.etree.ElementTree as ET # noqa:N817 from typing import List, Tuple import pandas # type: ignore diff --git a/investments/ibdds/ibdds.py b/investments/ibdds/ibdds.py index 4207609..1e7c87c 100644 --- a/investments/ibdds/ibdds.py +++ b/investments/ibdds/ibdds.py @@ -67,7 +67,7 @@ def show_report(cash: List[Cash]): deposits_amount = dds_specific_round(deposits_amount) withdrawals_amount = dds_specific_round(withdrawals_amount) - report : List[List[Any]] = [ + report: List[List[Any]] = [ [f'{currency.name} {currency.iso_numeric_code()}', 'Сумма в тысячах единиц'], ['Остаток денежных средств на счете на начало отчетного периода', begin_amount], ['Зачислено денежных средств за отчетный период', deposits_amount], diff --git a/investments/ibtax/ibtax.py b/investments/ibtax/ibtax.py index 18233f5..ae8b8e0 100644 --- a/investments/ibtax/ibtax.py +++ b/investments/ibtax/ibtax.py @@ -13,7 +13,7 @@ from investments.interests import Interest from investments.money import Money from investments.report_parsers.ib import InteractiveBrokersReportParser -from investments.trades_fifo import TradesAnalyzer, FinishedTrade, PortfolioElement # noqa: I001 +from investments.trades_fifo import FinishedTrade, PortfolioElement, TradesAnalyzer def apply_round_for_dataframe(source: pandas.DataFrame, columns: Iterable, digits: int = 2) -> pandas.DataFrame: diff --git a/investments/report_parsers/open_fr.py b/investments/report_parsers/open_fr.py index fa34dd0..4698ab7 100644 --- a/investments/report_parsers/open_fr.py +++ b/investments/report_parsers/open_fr.py @@ -1,6 +1,6 @@ import datetime import re -import xml.etree.ElementTree as ET # type: ignore +import xml.etree.ElementTree as ET # noqa:N817 from typing import List, Optional from investments.currency import Currency