Skip to content
This repository was archived by the owner on Feb 19, 2023. It is now read-only.

Linting check of use of string join() with generator expression #26

Merged
merged 5 commits into from Jul 12, 2021
Merged

Linting check of use of string join() with generator expression #26

merged 5 commits into from Jul 12, 2021

Conversation

ghost
Copy link

@ghost ghost commented Jul 1, 2021

As requested in pandas #42173, a linting check of the use of string join() with generator expression is added.

@MarcoGorelli
Copy link
Member

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

@ghost
Copy link
Author

ghost commented Jul 10, 2021

Hi, @MarcoGorelli!
Ok!

Copy link
Member

@MarcoGorelli MarcoGorelli left a 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?

@ghost
Copy link
Author

ghost commented Jul 11, 2021

Ok!
I'll fix that!

@ghost
Copy link
Author

ghost commented Jul 12, 2021

Hi, @MarcoGorelli!
I have fixed the coverage.

@codecov
Copy link

codecov bot commented Jul 12, 2021

Codecov Report

Merging #26 (f39b9fe) into main (8be2d08) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
pandas_dev_flaker/_ast_helpers.py 100.00% <100.00%> (ø)
...dev_flaker/_plugins_tree/generator_join_strings.py 100.00% <100.00%> (ø)
tests/generator_join_strings_test.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8be2d08...f39b9fe. Read the comment docs.

Comment on lines 39 to 41
python_version = float(sys.version_info.major) + 0.1 * float(
sys.version_info.minor,
)
Copy link
Member

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

Copy link
Member

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...

Copy link
Author

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!

Comment on lines 43 to 49
(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)
)
)
Copy link
Member

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?

Copy link
Author

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.

Copy link
Member

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!

) -> bool:
return isinstance(node.func, ast.Attribute) and (
(
sys.version_info[0:2] < (3, 8)
Copy link
Member

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)

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome, thanks!

@MarcoGorelli MarcoGorelli merged commit ca1fec6 into pandas-dev:main Jul 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant