-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
for issue #49656 STYLE enable pylint's redefined-outer-name #49708
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
Conversation
pandas/core/generic.py
Outdated
from datetime import timedelta | ||
from datetime import timedelta as td |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would import datetime as dt
and then dt.timedelta
work?
pandas/core/generic.py
Outdated
common as com, | ||
common, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it work to just import the various functions from pandas.core.common
? from pandas.core.common import get_rename_function, ...
?
pandas/core/generic.py
Outdated
com=com, | ||
com=commmon, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shouldn't change
Done the changes sir |
pandas/core/generic.py
Outdated
indexing, | ||
missing, | ||
nanops, | ||
sample, | ||
) | ||
from pandas.core.common import get_rename_function as com |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no just
from pandas.core.common import get_rename_function
and then use get_rename_function
instead of com.get_rename_function
likewise for any other com.
functions
pandas/core/generic.py
Outdated
@@ -6318,7 +6317,8 @@ def _convert( | |||
self: NDFrameT, | |||
datetime: bool_t = False, | |||
numeric: bool_t = False, | |||
timedelta: bool_t = False, | |||
# td: bool_t = False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this
pandas/core/generic.py
Outdated
@@ -6318,7 +6317,8 @@ def _convert( | |||
self: NDFrameT, | |||
datetime: bool_t = False, | |||
numeric: bool_t = False, | |||
timedelta: bool_t = False, | |||
# td: bool_t = False, | |||
dt.timedelta: bool_t = False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shouldn't change, it's a function argument
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like with the other PR, you're introducing a number of changes which aren't valid Python syntax
Do you have much experience with Python? I'm tempted to suggest you do a bit more study before coming back to contribute
pandas/core/generic.py
Outdated
@@ -2,9 +2,8 @@ | |||
from __future__ import annotations | |||
|
|||
import collections | |||
from datetime import timedelta | |||
from datetime ad dt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't valid syntax...
yes sir |
Getting closer - can you also run
|
sir this error is coming |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you show your full output please?
@@ -2,9 +2,8 @@ | |||
from __future__ import annotations | |||
|
|||
import collections | |||
from datetime import timedelta | |||
import datetime as dt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now you'll need to replace timedelta
(not the function argument) with dt.timedelta
|
Looks like an issue with Anyway, for this issue, if you look at https://github.com/pandas-dev/pandas/actions/runs/3471395358/jobs/5800830394 it'll show you what the remaining issues are and what needs changing |
yes sir |
no such issure is reported there sir, should I write problem with autotyping and attach the output for reporting it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the
pandas/core/generic.py:9479:21: F402 import 'dt' from line 5 shadowed by loop variable
you can probably replace that dt
with _dt
as it's just a loop variable
pandas/core/generic.py
Outdated
@@ -142,6 +143,14 @@ | |||
from pandas.core.array_algos.replace import should_use_regex | |||
from pandas.core.arrays import ExtensionArray | |||
from pandas.core.base import PandasObject | |||
from pandas.core.common import ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we'll need to add # noqa: PDF018
as a comment here, we can't use the com
alias
yes |
pandas/core/generic.py
Outdated
@@ -2,9 +2,8 @@ | |||
from __future__ import annotations | |||
|
|||
import collections | |||
from datetime import timedelta | |||
import datetime as _dt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep this one as dt
it's
Lines 9470 to 9472 in 1f6e44a
for dt in cond.dtypes: | |
if not is_bool_dtype(dt): | |
raise ValueError(msg.format(dtype=dt)) |
that needs changing to _dt
pandas/core/generic.py
Outdated
@@ -31,7 +30,10 @@ | |||
|
|||
from pandas._config import config | |||
|
|||
from pandas._libs import lib | |||
from pandas._libs import ( | |||
json, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are you importing json from here instead of import json
? it's different
pandas/core/generic.py
Outdated
rs = com.random_state(random_state) | ||
rs = random_state(random_state) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now the random_state
argument from this function shadows the random_state
import
Might have to change the pandas.core.common
import back to from pandas.core import common
, but add the noqa
command to that line to silence the flake8 warning of the missing as com
alias
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done sir
pandas/core/generic.py
Outdated
@@ -130,10 +130,10 @@ | |||
notna, | |||
) | |||
|
|||
from pandas.core import common # noqa: PDF018 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this, the next lines should be
from pandas.core import (
algorithms as algos,
arraylike,
common, # noqa: PDF018
pandas/core/generic.py
Outdated
from pandas.core.common import ( # noqa: PDF018 | ||
apply_if_callable, | ||
count_not_none, | ||
get_rename_function, | ||
index_labels_to_array, | ||
maybe_make_list, | ||
pipe, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can remove these now
pandas/core/generic.py
Outdated
@@ -1009,7 +1017,7 @@ def _rename( | |||
continue | |||
|
|||
ax = self._get_axis(axis_no) | |||
f = com.get_rename_function(replacements) | |||
f = get_rename_function(replacements) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will have to be common.get_rename_function
(similarly for the others)
pandas/core/generic.py
Outdated
@@ -32,6 +31,7 @@ | |||
from pandas._config import config | |||
|
|||
from pandas._libs import lib | |||
import json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the imports are in the wrong order, if you run
pre-commit run black --files pandas/core/generic.py
pre-commit run isort --files pandas/core/generic.py
pre-commit run flake8 --files pandas/core/generic.py
before committing it should fix up most of the reported issues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done sir, and ran these tests all of them passed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ramvikrams for sticking with this, looks good now! 💪
All thanks to you sir for guiding me. |
…pandas-dev#49708) * t1 * update * update * Update generic.py * update * Update generic.py * Update generic.py * Update generic.py * Update generic.py * Update generic.py * Update generic.py * Update generic.py
…pandas-dev#49708) * t1 * update * update * Update generic.py * update * Update generic.py * Update generic.py * Update generic.py * Update generic.py * Update generic.py * Update generic.py * Update generic.py
@MarcoGorelli Sir in the file
pandas\core\generic.py
I had one doubt for line 7684and I could not understand how todo the correct changes in
pandas\core\resmple.py