From d6b35bc92bcdbc78539d5a5781f8de5bfc2f4f7b Mon Sep 17 00:00:00 2001
From: Maxim Andreev <andreevmaxim@gmail.com>
Date: Sun, 9 Jan 2022 18:37:41 +0300
Subject: [PATCH] fix flake8 errors

---
 .flake8                               | 7 +++----
 .isort.cfg                            | 2 ++
 investments/data_providers/cache.py   | 5 ++---
 investments/data_providers/cbr.py     | 2 +-
 investments/ibtax/ibtax.py            | 2 +-
 investments/report_parsers/open_fr.py | 2 +-
 6 files changed, 10 insertions(+), 10 deletions(-)
 create mode 100644 .isort.cfg

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 f376fda..de23d60 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 Dict, List, Optional, Tuple
 
 import pandas  # type: ignore
diff --git a/investments/ibtax/ibtax.py b/investments/ibtax/ibtax.py
index dcba642..b8951c7 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