windrose icon indicating copy to clipboard operation
windrose copied to clipboard

fix some of my messy previous change that broke theta_labels...

Open weber-s opened this issue 5 years ago • 4 comments

When fiwing a previous bug, I added a new one... Theta labels were not correctly displayed anymore.

Here is a fix + add some test.

weber-s avatar Sep 15 '20 12:09 weber-s

HéHé.

This code fails for python 2. Do we care about supporting it?

weber-s avatar Sep 15 '20 12:09 weber-s

Why not changing

def __init__(self, *args, theta_labels=DEFAULT_THETA_LABELS, **kwargs)

to

def __init__(self, *args, **kwargs)

and get theta_labels from kwargs if it exists or default it to DEFAULT_THETA_LABELS

so it will works both with Python 2.7 and 3.x

But the question on dropping Python 2.7 should be considered

s-celles avatar Sep 15 '20 12:09 s-celles

You should also avoid passing list as a default parameter according https://florimond.dev/blog/articles/2018/08/python-mutable-defaults-are-the-source-of-all-evil/

(use None instead)

s-celles avatar Sep 15 '20 12:09 s-celles

Indeed. It's just that I am not a fan of "kwar.poping" things, because it hide the potential argument of the function.

For the mutable argument, I agree. Normally it is never modified so I did it, but sure it may cause bug later on.

weber-s avatar Sep 15 '20 12:09 weber-s

@scls19fr I know you already approved this one but do you mind taking a second look? I rebased and fixed the tests, it should be good to go.

PS: in a way this implements https://github.com/python-windrose/windrose/pull/120

ocefpaf avatar Sep 21 '22 14:09 ocefpaf