-
-
Notifications
You must be signed in to change notification settings - Fork 183
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
remove object class from base classes in type calls #731
Conversation
as this tests a noop, the result should be equal to src
…ins/type_bases_object as it is not shared
… calls, adding arguments to support the difference between the two cases
@asottile what should be done for |
so the weird thing is >>> x = type('a', (), {})
>>> x.__bases__
(<type 'object'>,) I would probably remove it anyway 🤷 |
…hrough all tokens
…ed with empty bases)
# Conflicts: # pyupgrade/_plugins/type_bases_object.py
…and type calls, adding arguments to support the difference between the two cases" This reverts commit f1afe8e
type_start = find_open_paren(tokens, 0) | ||
bases_start = find_open_paren(tokens, type_start + 1) | ||
bases, end = parse_call_args(tokens, bases_start) | ||
for base_start, base_end in bases: # pragma: no cover |
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't ship with this -- means you haven't tested everything
this function is way too complicated -- I don't think it's correct either. you should also be able to use the original object
base index without needing to re-find it here and utilize the argument removal functions
|
||
def remove_base_class_from_type_call(i: int, tokens: list[Token]) -> None: | ||
type_start = find_open_paren(tokens, 0) | ||
bases_start = find_open_paren(tokens, type_start + 1) |
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 necessarily correct -- type(class_name(), (...))
del tokens[base_start:base_end] | ||
# (foo, bar, ..., object[,]) -> (foo, bar, ...[,]) | ||
else: | ||
if tokens[base_end - 1].name == UNIMPORTANT_WS and \ |
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.
don't use backslashes
I won't have much time to work on this anymore :/ -- closing the PR so others might take a stab at this p.s. thank you for being patient with me through this (my first contribution), this was an educating experience :) |
This solves #532