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

STYLE: Fix Pylint Style Checks For used-before-assignment #48940

Merged
merged 6 commits into from
Nov 15, 2022

Conversation

Leviob
Copy link
Contributor

@Leviob Leviob commented Oct 4, 2022

  • xref STYLE fix pylint issues #48855 - one of many style checks, still needs work.
  • All code checks passed.
  • Moved initialization of dispcmd, fd, new_f outside of their respective try blocks to ensure they are defined
  • Added Pylint disable statements for false positive warnings for _is_scipy_sparse, groupby, and Series
  • Removed possibly undefined variable no_mpl_message
  • Moved f.close() to try block to ensure f is defined if it is called

@MarcoGorelli MarcoGorelli self-requested a review October 4, 2022 20:36
@mroeschke mroeschke added the Code Style Code style, linting, code_checks label Oct 5, 2022
@@ -883,10 +883,9 @@ def test_to_excel_unicode_filename(self, ext):
with tm.ensure_clean("\u0192u." + ext) as filename:
try:
f = open(filename, "wb")
f.close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just:

with open(filename, "wb") as f:
    pass

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smart. Thanks.

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

Looks like there's some false positives, which have been flagged to pylint - shall we wait to see if they respond and fix this? pylint-dev/pylint#7574

@Leviob
Copy link
Contributor Author

Leviob commented Oct 6, 2022

I don't know what's causing the CI testing to fail now. Do I need to change anything to fix that?

@MarcoGorelli
Copy link
Member

it's unrelated, don't worry about it, let's just wait a bit to see if it looks like pylint might make a release which fixes it

@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2022

This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this.

@github-actions github-actions bot added the Stale label Nov 6, 2022
Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Leviob - it doesn't look like this'll be fixed in pylint anytime soon, so let's just turn the check off in those 2-3 places

I've left a couple of comments - could you fetch and merge upstream/main please?

pandas/core/tools/datetimes.py Outdated Show resolved Hide resolved
pandas/core/groupby/indexing.py Outdated Show resolved Hide resolved
@MarcoGorelli MarcoGorelli added this to the 2.0 milestone Nov 15, 2022
Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Leviob !

@MarcoGorelli MarcoGorelli merged commit 97edd8e into pandas-dev:main Nov 15, 2022
MarcoGorelli pushed a commit to MarcoGorelli/pandas that referenced this pull request Nov 18, 2022
…#48940)

* STYLE: Fix Pylint Style Checks For used-before-assignment

* Refactor: Use 'with open' instead of open/close

* CLN: disable used-before-assignment warning

* CLN: Remove used-before-assignment from pyproject.toml

* CLN: disable used-before-assignment warning in-line
mliu08 pushed a commit to mliu08/pandas that referenced this pull request Nov 27, 2022
…#48940)

* STYLE: Fix Pylint Style Checks For used-before-assignment

* Refactor: Use 'with open' instead of open/close

* CLN: disable used-before-assignment warning

* CLN: Remove used-before-assignment from pyproject.toml

* CLN: disable used-before-assignment warning in-line
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.

3 participants