Skip to content

CLN upgrade to Python3.7+ syntax #36450

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

Closed
11 of 54 tasks
MarcoGorelli opened this issue Sep 18, 2020 · 2 comments · Fixed by #36457
Closed
11 of 54 tasks

CLN upgrade to Python3.7+ syntax #36450

MarcoGorelli opened this issue Sep 18, 2020 · 2 comments · Fixed by #36457
Labels
Clean Code Style Code style, linting, code_checks good first issue
Milestone

Comments

@MarcoGorelli
Copy link
Member

MarcoGorelli commented Sep 18, 2020

Given that the next release will we Python3.7+, we might as well upgrade some of the syntax, e.g.

-    for make_index_func in make_index_funcs:
-        yield make_index_func
+    yield from make_index_funcs

or

-            return "%s[%s, %s]" % (cls, tp_repr, metadata_reprs)
+            return f"{cls}[{tp_repr}, {metadata_reprs}]"

We can do this using pyupgrade.

Here are the files that can be upgraded:

  • pandas/_config/display.py
  • pandas/_testing.py
  • pandas/_vendored/typing_extensions.py
  • pandas/_version.py
  • pandas/core/arrays/datetimes.py
  • pandas/core/arrays/sparse/array.py
  • pandas/core/common.py
  • pandas/core/computation/expr.py
  • pandas/core/computation/pytables.py
  • pandas/core/generic.py
  • pandas/core/groupby/base.py
  • pandas/core/groupby/generic.py
  • pandas/core/indexes/base.py
  • pandas/core/indexes/datetimelike.py
  • pandas/core/reshape/merge.py
  • pandas/io/clipboard/init.py
  • pandas/io/formats/excel.py
  • pandas/io/html.py
  • pandas/io/json/_json.py
  • pandas/io/pytables.py
  • pandas/io/stata.py
  • pandas/plotting/_matplotlib/core.py
  • pandas/tests/arrays/categorical/test_constructors.py
  • pandas/tests/arrays/integer/test_construction.py
  • pandas/tests/extension/decimal/array.py
  • pandas/tests/extension/test_categorical.py
  • pandas/tests/frame/test_constructors.py
  • pandas/tests/groupby/test_groupby.py
  • pandas/tests/groupby/test_grouping.py
  • pandas/tests/indexes/test_base.py
  • pandas/tests/indexing/test_indexing.py
  • pandas/tests/io/formats/test_format.py
  • pandas/tests/io/formats/test_to_csv.py
  • pandas/tests/io/formats/test_to_html.py
  • pandas/tests/io/formats/test_to_latex.py
  • pandas/tests/io/json/test_ujson.py
  • pandas/tests/io/parser/test_c_parser_only.py
  • pandas/tests/io/parser/test_common.py
  • pandas/tests/io/parser/test_encoding.py
  • pandas/tests/io/parser/test_read_fwf.py
  • pandas/tests/io/pytables/common.py
  • pandas/tests/io/test_common.py
  • pandas/tests/io/test_html.py
  • pandas/tests/io/test_sql.py
  • pandas/tests/reshape/test_get_dummies.py
  • pandas/tests/scalar/test_na_scalar.py
  • pandas/tests/series/test_analytics.py
  • pandas/tests/series/test_constructors.py
  • pandas/tests/series/test_dtypes.py
  • pandas/tests/series/test_io.py
  • scripts/validate_rst_title_capitalization.py
  • scripts/validate_unwanted_patterns.py
  • setup.py
  • versioneer.py

If you're intereseted in helping out, please choose a batch of 10-15 to run pyupgrade on.

Install pyupgrade with:

pip install pyupgrade==2.7.2

Then, run

pyupgrade <files you want to upgrade> --py37-plus

e.g.

pyupgrade pandas/tests/io/test_html.py pandas/tests/io/json/test_ujson.py --py37-plus

See #36453 for an example PR.

Once this is done, we can add it to pre-commit / CI.

@ahgamut
Copy link
Contributor

ahgamut commented Sep 18, 2020

I'll try to submit a PR for this. take

ahgamut added a commit to ahgamut/pandas that referenced this issue Sep 18, 2020
Ran pyupgrade on all files unchecked in pandas-dev#36450. formatter pre-commit
hook had no complaints; removed unnecessary imports from the following
to satisfy flake8 hook:

pandas/tests/io/test_sql.py
pandas/tests/io/parser/test_read_fwf.py
pandas/test/series/test_io.py
ahgamut added a commit to ahgamut/pandas that referenced this issue Sep 18, 2020
Ran pyupgrade on all files unchecked in pandas-dev#36450. formatter pre-commit
hook had no complaints; removed unnecessary imports from the following
to satisfy flake8 hook:

pandas/tests/io/test_sql.py
pandas/test/series/test_io.py
@ahgamut
Copy link
Contributor

ahgamut commented Sep 18, 2020

I've submitted #36457 for all the unchecked files.
It passes all CI checks but one (travis-ci build timeout).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Code Style Code style, linting, code_checks good first issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants