-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
STY: Changed x.__class__ to type(x) #29816
Conversation
Is this supposed to make any difference in Python3 or just a stylistic thing? If so, lgtm |
Pure stylistic change. trying to be consistent. something that was mentioned here. |
Two questions, not blockers
|
The Python docs explains this much better. In 2 lines summary it goes like this:
The detailed explanation bellow: The way I see it if you're comparing only >>> my_str = 'Example'
>>> type(my_str)
<class 'str'>
>>> type(type(my_str))
<class 'type'> But if you add >>> my_int = 1
>>> type(my_int).__name__
'int'
>>> type(type(my_int).__name__)
<class 'str'> P.S |
Mostly more confusing; I think the focus needs to be on |
@jbrockmendel Now I'm confused lol.
Can you give an example(preferably code) of what is preferred and what should not be? Would love to correct my PR accordingly. |
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.
lgtm. can you implement a code_check for the now banned format as well? (basically grep for self.__class__
i think would be enough
@jreback TBH no, I have no clue on to approach that (writing tests). Plus I don't think a simple grep will do the work unfortunately. there are files like pandas/pandas/core/indexing.py Line 108 in de28255
But I do think that if we ban the |
why is this ok? that should simply be |
Gave me an error when I tried exactly what you wrote. |
@MomIsBestFriend pls ignore my previous comment(s), it looks like they only made things more confusing without being productive. This PR was/is fine before I started talking. @jreback let's hold off on a code check for the next round; the diff here is already wide-reaching. |
@jreback looks like |
6aa8ced
to
6e761a3
Compare
94409ec
to
7816ae5
Compare
Since this PR got too large, and I can't detect where is the error, I'm closing it. |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff