-
-
Notifications
You must be signed in to change notification settings - Fork 7
Linting check of use of string join() with generator expression #26
Conversation
Hey @vrserpa - thanks for doing this! Somehow I didn't get a notification (looks like I'd accidentally unwatched this repo), so sorry for the delay I'll take a look at the weekend |
Hi, @MarcoGorelli! |
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 is off to a good start! Looks like coverage has dropped below 100%, could you please fix that up?
Ok! |
Hi, @MarcoGorelli! |
Codecov Report
@@ Coverage Diff @@
## main #26 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 49 51 +2
Lines 659 685 +26
Branches 84 86 +2
=========================================
+ Hits 659 685 +26
Continue to review full report at Codecov.
|
pandas_dev_flaker/_ast_helpers.py
Outdated
python_version = float(sys.version_info.major) + 0.1 * float( | ||
sys.version_info.minor, | ||
) |
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.
😄 never do this, just use sys.version_info
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.
besides, ask yourself what would happen for Python 3.10
...
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.
Sorry 😄
I'm gonna fix that!
pandas_dev_flaker/_ast_helpers.py
Outdated
(python_version < 3.8 and isinstance(node.func.value, ast.Str)) | ||
or ( | ||
python_version >= 3.8 | ||
and isinstance(node.func.value, ast.Constant) | ||
and isinstance(node.func.value.value, str) | ||
) | ||
) |
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 not work to just use
isinstance(node.func.value, ast.Str)
in all versions of Python?
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.
ast.Str
is deprecated since python 3.8. It will be removed in future python releases, according to ast.
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.
ah, I wasn't aware, thanks!
pandas_dev_flaker/_ast_helpers.py
Outdated
) -> bool: | ||
return isinstance(node.func, ast.Attribute) and ( | ||
( | ||
sys.version_info[0:2] < (3, 8) |
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.
you can just do sys.version_info < (3, 8)
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.
As requested in pandas #42173, a linting check of the use of string join() with generator expression is added.