You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adjustment: Cover casese, which are ignored for now
Explanation
For SIM118 package cannot handle any NotIn type of expressions, only In, which is not covering one of cases. For SIM108 package ignores the case when line of new code is more than 79 characters, which should adjusted as warning of line length and shoudn't be ignored. Ruff, for example can determine them.
Example
This is an example where the mentioned rule(s) would currently be suboptimal:
# SIM118ifkeyindict.keys(): # returns the rule error
...
ifkeynotindict.keys(): # ignores
...
# SIM108ifa:
b=celse:
b=d# New code will be less than 79 and error will not be ignorediflong_varialbe_name:
long_one_second=something_ifelse:
long_one_second=something_else# New code wil exceed 79 length and error will be igonred
Soltions
# Solution for ast_compare.py:get_sim118
...
RULE="SIM118 Use '{el} in {dict}' instead of '{el} in {dict}.keys()'"errors: List[Tuple[int, int, str]] = []
ifnot (
len(node.ops) ==1and (
isinstance(node.ops[0], ast.In) orisinstance(node.ops[0], ast.NotIn) # here is the new case
)
andlen(node.comparators) ==1
):
returnerrors
...
# Solution for ast_if.py:get_sim108
...
new_code=RULE.format(assign=assign, body=body, cond=cond, orelse=orelse)
iflen(new_code) >79:
new_code+='. This line will exceed 79 characters, please, be sure, that you will control it.'# now all cases will not be ignored and just add new warning to iterrors.append((node.lineno, node.col_offset, new_code))
...
The text was updated successfully, but these errors were encountered:
Desired change
Explanation
For SIM118 package cannot handle any NotIn type of expressions, only In, which is not covering one of cases. For SIM108 package ignores the case when line of new code is more than 79 characters, which should adjusted as warning of line length and shoudn't be ignored. Ruff, for example can determine them.
Example
This is an example where the mentioned rule(s) would currently be suboptimal:
Soltions
The text was updated successfully, but these errors were encountered: