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

Rewrite dict literal for files in pandas/tests/frame #38207

Merged
merged 1 commit into from
Dec 2, 2020

Conversation

Qbiwan
Copy link
Contributor

@Qbiwan Qbiwan commented Dec 1, 2020

  • xref CLN: C408 Unnecessary dict call - rewrite as a literal #38138

  • tests added / passed

  • passes black pandas

  • passes git diff upstream/master -u -- "*.py" | flake8 --diff

  • whatsnew entry
    identify unnecessary dict call - rewrite as a literal
    Rewrites as dictionary literals for the following files:

    modified: pandas/tests/frame/indexing/test_indexing.py
    modified: pandas/tests/frame/indexing/test_where.py
    modified: pandas/tests/frame/methods/test_fillna.py
    modified: pandas/tests/frame/methods/test_sort_values.py
    modified: pandas/tests/frame/methods/test_to_csv.py
    modified: pandas/tests/frame/methods/test_to_records.py
    modified: pandas/tests/frame/test_arithmetic.py
    modified: pandas/tests/frame/test_reductions.py

However, I did not change it to literal in the following two places, as they seem like valid dict call:

  1. pandas/tests/frame/indexing/test_indexing.py
lambda l: dict(zip(l, range(len(l)))),   # line 76
lambda l: dict(zip(l, range(len(l)))).keys(),  # line 77
  1. pandas/tests/frame/indexing/test_where.py
return DataFrame(dict((c, s + 1) if is_ok(s) else (c, s) for c, s in df.items()))  # line 32

@jreback jreback added the Code Style Code style, linting, code_checks label Dec 2, 2020
@jreback
Copy link
Contributor

jreback commented Dec 2, 2020

both of 1 and 2 can be dict-comprehensions. (can do separately).

@jreback jreback added this to the 1.2 milestone Dec 2, 2020
@jreback jreback merged commit b687883 into pandas-dev:master Dec 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Style Code style, linting, code_checks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants