Closed jvlmdr closed 4 years ago
Yeah, I totally agree that duplicating the code in __init__()
and reset()
is not as nice as before. I did this to fix the following lint warnings (attribute-defined-outside-init):
motmetrics/mot.py:163:8: W0201: Attribute 'dirty_events' defined outside __init__ (attribute-defined-outside-init)
motmetrics/mot.py:304:12: W0201: Attribute 'dirty_events' defined outside __init__ (attribute-defined-outside-init)
motmetrics/mot.py:303:12: W0201: Attribute 'cached_events_df' defined outside __init__ (attribute-defined-outside-init)
These warnings occur at the sites where those member variables are accessed. (The linter isn't smart enough to realise that reset()
is called within __init__()
.)
I didn't want to disable this warning globally because I think it is good to define the member variables in __init__()
where possible.
I propose two options:
reset()
, simply set all those variable to None and then call reset()
.What do you think?
looking good. did you disable the warning? haven't found a reference.
I did option 2 (initialize all state variables to None in the constructor) rather than option 1 (disable the warning). See the diff here
Ah ok, didn't spot that. Then lets merge! Thanks Jack 😀
Jack Valmadre notifications@github.com schrieb am Sa., 1. Feb. 2020, 15:44:
I did option 2 (initialize all state variables to None in the constructor) rather than option 1 (disable the warning). jvlmdr/py-motmetrics@jvlmdr:613e1e7...jvlmdr:c1a7228 diff-8a7fa6c9ecbaabedee2e2dadd0e08b01R109 https://github.com/jvlmdr/py-motmetrics/compare/jvlmdr:613e1e7...jvlmdr:c1a7228diff-8a7fa6c9ecbaabedee2e2dadd0e08b01R109
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/cheind/py-motmetrics/pull/76?email_source=notifications&email_token=AAAJNJO7ZILGJVPMA47TBUTRAWDGTA5CNFSM4KN546R2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKQ6WZQ#issuecomment-581036902, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAJNJMAKJIPVCNA62KNMH3RAWDGTANCNFSM4KN546RQ .
Excellent! Thanks for taking a look!
Hey, any objections to doing this?