-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Make rcsetup.py flak8 compliant #12543
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
Conversation
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.
Welcome to matplotlib and thanks for your contribution! Please be aware that, while some flake8 execeptions are there because of historical non-compliant code, we leave others intentionally in place.
lib/matplotlib/rcsetup.py
Outdated
@@ -74,7 +74,8 @@ def f(s): | |||
if allow_stringlist: | |||
# Sometimes, a list of colors might be a single string | |||
# of single-letter colornames. So give that a shot. | |||
return [scalar_validator(v.strip()) for v in s if v.strip()] | |||
return [scalar_validator(v.strip()) for v in s if | |||
v.strip()] |
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.
The preferred way to split list comprehensions is before the keyword for
(and/or if
if additionally required:
return [scalar_validator(v.strip())
for v in s if v.strip()]
This keeps the logical blocks together.
lib/matplotlib/rcsetup.py
Outdated
# http://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html | ||
# We should replace this eval with a combo of PyParsing and | ||
# ast.literal_eval() | ||
# TODO: We might want to rethink this... |
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.
Why are you dedenting here? This was correctly indented 4 spaces.
lib/matplotlib/rcsetup.py
Outdated
@@ -1012,7 +1015,7 @@ def _validate_linestyle(ls): | |||
'lines.solid_joinstyle': ['round', validate_joinstyle], | |||
'lines.dash_capstyle': ['butt', validate_capstyle], | |||
'lines.solid_capstyle': ['projecting', validate_capstyle], | |||
'lines.dashed_pattern': [[3.7, 1.6], validate_nseq_float(allow_none=True)], | |||
'lines.dashed_pattern': [[3.7, 1.6], validate_nseq_float(allow_none=True)], |
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.
While generally, we try to be flake8 conform, I would not insist on line length limits for the definition of the default parameters. These definitions should be kept as structured as possible. I thus propose to leave E501 in and limit the changes to defaultParams
to cases where we do not have to bent over or excessively stretch comments over serveral lines to satisfy the line limit.
07af35f
to
e0e068f
Compare
Thanks @timhoffm. |
Thanks @hershen and congratulations to your first contribution to matplotlib! |
Thanks! |
PR Summary
Inspired by #12525, this PR makes rcsetup.py flake8 compliant.