Skip to content

STYLE enable pylint: undefined-variable #49898

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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _process_single_doc(self, single_doc):

elif single_doc.startswith("pandas."):
try:
obj = pandas # noqa: F821
obj = pandas # pylint: disable=undefined-variable # noqa: F821
for name in single_doc.split("."):
obj = getattr(obj, name)
except AttributeError as err:
Expand Down
16 changes: 8 additions & 8 deletions pandas/io/clipboard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ def paste_osx_pbcopy():


def init_osx_pyobjc_clipboard():
try:
import AppKit
import Foundation # check if pyobjc is installed
except ImportError:
return init_osx_pbcopy_clipboard()
Comment on lines +127 to +131
Copy link
Member

Choose a reason for hiding this comment

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

thanks for looking into this!

not sure about returning init_osx_pbcopy_clipboard within init_osx_pyobjc_clipboard

I think pylint might not be correct here, e.g. if we have

def foo():
    print(re)

def bar():
    global re
    try:
        import re
    except ImportError:
        pass
    else:
        foo()

bar()

then it executes just fine

Shall just keep as-is and turn off the warning?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, @MarcoGorelli for the example. Sure thing, let’s keep this warning turn off.


def copy_osx_pyobjc(text):
"""Copy string argument to clipboard"""
text = _stringifyText(text) # Converts non-str values to str.
Expand Down Expand Up @@ -512,7 +518,7 @@ def determine_clipboard():
Determine the OS/platform and set the copy() and paste() functions
accordingly.
"""
global Foundation, AppKit, qtpy, PyQt4, PyQt5
global qtpy, PyQt4, PyQt5

# Setup for the CYGWIN platform:
if (
Expand All @@ -539,13 +545,7 @@ def determine_clipboard():

# Setup for the macOS platform:
if os.name == "mac" or platform.system() == "Darwin":
try:
import AppKit
import Foundation # check if pyobjc is installed
except ImportError:
return init_osx_pbcopy_clipboard()
else:
return init_osx_pyobjc_clipboard()
return init_osx_pyobjc_clipboard()

# Setup for the LINUX platform:
if HAS_DISPLAY:
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ disable = [
"abstract-class-instantiated",
"redundant-keyword-arg",
"no-value-for-parameter",
"undefined-variable",
"unpacking-non-sequence",

# pylint type "C": convention, for programming standard violation
Expand Down