From c61bea435a2822c26bfbd709f5bbe21a4ccb0268 Mon Sep 17 00:00:00 2001 From: Michael Marino Date: Wed, 13 May 2020 08:57:42 +0200 Subject: [PATCH 1/6] Temporarily ignore linting errors --- setup.cfg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.cfg b/setup.cfg index d0216a05a2268..77fa1249b7fba 100644 --- a/setup.cfg +++ b/setup.cfg @@ -19,6 +19,8 @@ ignore = W504, # line break after binary operator E402, # module level import not at top of file E731, # do not assign a lambda expression, use a def + E741, # ambiguous variable name 'l' (GH#34150) + F541, # f-string is missing placeholders *GH#34150) C406, # Unnecessary list literal - rewrite as a dict literal. C408, # Unnecessary dict call - rewrite as a literal. C409, # Unnecessary list passed to tuple() - rewrite as a tuple literal. From 8b9ea475666125b6936dd53b3dbe04785d77a72b Mon Sep 17 00:00:00 2001 From: Michael Marino Date: Wed, 13 May 2020 09:31:27 +0200 Subject: [PATCH 2/6] Remove unnecessary f-strings --- pandas/core/series.py | 5 +---- pandas/tests/groupby/aggregate/test_numba.py | 4 ++-- pandas/tests/groupby/transform/test_numba.py | 4 ++-- pandas/tests/io/test_stata.py | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 74dcdaee327da..4ba9a0c925a5d 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -2584,10 +2584,7 @@ def append(self, to_append, ignore_index=False, verify_integrity=False): else: to_concat = [self, to_append] if any(isinstance(x, (ABCDataFrame,)) for x in to_concat[1:]): - msg = ( - f"to_append should be a Series or list/tuple of Series, " - f"got DataFrame" - ) + msg = "to_append should be a Series or list/tuple of Series, got DataFrame" raise TypeError(msg) return concat( to_concat, ignore_index=ignore_index, verify_integrity=verify_integrity diff --git a/pandas/tests/groupby/aggregate/test_numba.py b/pandas/tests/groupby/aggregate/test_numba.py index f23d7765eb508..726d79535184a 100644 --- a/pandas/tests/groupby/aggregate/test_numba.py +++ b/pandas/tests/groupby/aggregate/test_numba.py @@ -18,10 +18,10 @@ def incorrect_function(x): {"key": ["a", "a", "b", "b", "a"], "data": [1.0, 2.0, 3.0, 4.0, 5.0]}, columns=["key", "data"], ) - with pytest.raises(NumbaUtilError, match=f"The first 2"): + with pytest.raises(NumbaUtilError, match="The first 2"): data.groupby("key").agg(incorrect_function, engine="numba") - with pytest.raises(NumbaUtilError, match=f"The first 2"): + with pytest.raises(NumbaUtilError, match="The first 2"): data.groupby("key")["data"].agg(incorrect_function, engine="numba") diff --git a/pandas/tests/groupby/transform/test_numba.py b/pandas/tests/groupby/transform/test_numba.py index e2b957f1a7ae7..9a4015ac983c5 100644 --- a/pandas/tests/groupby/transform/test_numba.py +++ b/pandas/tests/groupby/transform/test_numba.py @@ -17,10 +17,10 @@ def incorrect_function(x): {"key": ["a", "a", "b", "b", "a"], "data": [1.0, 2.0, 3.0, 4.0, 5.0]}, columns=["key", "data"], ) - with pytest.raises(NumbaUtilError, match=f"The first 2"): + with pytest.raises(NumbaUtilError, match="The first 2"): data.groupby("key").transform(incorrect_function, engine="numba") - with pytest.raises(NumbaUtilError, match=f"The first 2"): + with pytest.raises(NumbaUtilError, match="The first 2"): data.groupby("key")["data"].transform(incorrect_function, engine="numba") diff --git a/pandas/tests/io/test_stata.py b/pandas/tests/io/test_stata.py index e670e0cdf2ade..698b5417b471b 100644 --- a/pandas/tests/io/test_stata.py +++ b/pandas/tests/io/test_stata.py @@ -1861,7 +1861,7 @@ def test_writer_118_exceptions(self): @pytest.mark.parametrize("version", [105, 108, 111, 113, 114]) def test_backward_compat(version, datapath): data_base = datapath("io", "data", "stata") - ref = os.path.join(data_base, f"stata-compat-118.dta") + ref = os.path.join(data_base, "stata-compat-118.dta") old = os.path.join(data_base, f"stata-compat-{version}.dta") expected = pd.read_stata(ref) old_dta = pd.read_stata(old) From 5249f8d8ab0bb2c4051364ada5dcf5641da28a91 Mon Sep 17 00:00:00 2001 From: Michael Marino Date: Wed, 13 May 2020 09:33:01 +0200 Subject: [PATCH 3/6] Fix f-string in test --- pandas/tests/groupby/test_categorical.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/tests/groupby/test_categorical.py b/pandas/tests/groupby/test_categorical.py index 4560c7385655d..f9e89d36084c6 100644 --- a/pandas/tests/groupby/test_categorical.py +++ b/pandas/tests/groupby/test_categorical.py @@ -502,9 +502,9 @@ def test_dataframe_categorical_ordered_observed_sort(ordered, observed, sort): aggr[aggr.isna()] = "missing" if not all(label == aggr): msg = ( - f"Labels and aggregation results not consistently sorted\n" - + "for (ordered={ordered}, observed={observed}, sort={sort})\n" - + "Result:\n{result}" + "Labels and aggregation results not consistently sorted\n" + f"for (ordered={ordered}, observed={observed}, sort={sort})\n" + f"Result:\n{result}" ) assert False, msg From c0145c804833a6684d92c9b7c04d9cda08804b74 Mon Sep 17 00:00:00 2001 From: Michael Marino Date: Wed, 13 May 2020 09:33:43 +0200 Subject: [PATCH 4/6] Remove ignore f-string linting errors --- setup.cfg | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 77fa1249b7fba..ea3d4c67d9358 100644 --- a/setup.cfg +++ b/setup.cfg @@ -20,7 +20,6 @@ ignore = E402, # module level import not at top of file E731, # do not assign a lambda expression, use a def E741, # ambiguous variable name 'l' (GH#34150) - F541, # f-string is missing placeholders *GH#34150) C406, # Unnecessary list literal - rewrite as a dict literal. C408, # Unnecessary dict call - rewrite as a literal. C409, # Unnecessary list passed to tuple() - rewrite as a tuple literal. From 5ef7fb0d6a19052d03d34134efd4263f6da6558d Mon Sep 17 00:00:00 2001 From: Michael Marino Date: Wed, 13 May 2020 09:53:09 +0200 Subject: [PATCH 5/6] Add blank line for PEP8 compliance --- pandas/core/arrays/interval.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/core/arrays/interval.py b/pandas/core/arrays/interval.py index 32c170ba29ef1..cf15f36cb03a3 100644 --- a/pandas/core/arrays/interval.py +++ b/pandas/core/arrays/interval.py @@ -1049,6 +1049,7 @@ def mid(self): points) and is either monotonic increasing or monotonic decreasing, else False. """ + # https://github.com/python/mypy/issues/1362 # Mypy does not support decorated properties @property # type: ignore From 49a038cd0dd79d268638c5510be722d80168ca7e Mon Sep 17 00:00:00 2001 From: Michael Marino Date: Wed, 13 May 2020 10:01:08 +0200 Subject: [PATCH 6/6] Use isinstance instead of comparing types --- pandas/core/internals/concat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/internals/concat.py b/pandas/core/internals/concat.py index f02ad2102c15b..e25c4c2341217 100644 --- a/pandas/core/internals/concat.py +++ b/pandas/core/internals/concat.py @@ -443,7 +443,7 @@ def _is_uniform_join_units(join_units: List[JoinUnit]) -> bool: # cannot necessarily join return ( # all blocks need to have the same type - all(type(ju.block) is type(join_units[0].block) for ju in join_units) + all(isinstance(ju.block, type(join_units[0].block)) for ju in join_units) and # noqa # no blocks that would get missing values (can lead to type upcasts) # unless we're an extension dtype.