Closed jakkdl closed 1 year ago
I'm not entirely happy with the logic here, it now checks function names only against the last part of any specified pattern - which means that a startable function
foo
in modulebar
, that's only ever used in the code asbar.foo
, will never prompt you to add it if there's a pattern forother_module.foo
. Shared function names across modules/classes is pretty common, so means you can't relax and rely on TRIO114 to remind you every time you forget a method.
I'm actually OK with this; in practice all my patterns consist of either a bare name
or *.name
, which is handled. More generally, the error model for TRIO114 is "contributor didn't know or forgot to add the new startable thing", which I think is still pretty well covered.
As a backup manual check, grepping for task_status.*=trio\.TASK_STATUS_IGNORED
and cross-referencing the config works well - I did that for my code, and then thought of this new check when considering what would happen to the list as other people add new code 🙂
✅ Found a function that my grepping had missed, though registering it didn't trigger any new TRIO113 warnings 😁
I'm not entirely happy with the logic here, it now checks function names only against the last part of any specified pattern - which means that a startable function
foo
in modulebar
, that's only ever used in the code asbar.foo
, will never prompt you to add it if there's a pattern forother_module.foo
. Shared function names across modules/classes is pretty common, so means you can't relax and rely on TRIO114 to remind you every time you forget a method.I'm actually OK with this; in practice all my patterns consist of either a bare
name
or*.name
, which is handled. More generally, the error model for TRIO114 is "contributor didn't know or forgot to add the new startable thing", which I think is still pretty well covered.As a backup manual check, grepping for
task_status.*=trio\.TASK_STATUS_IGNORED
and cross-referencing the config works well - I did that for my code, and then thought of this new check when considering what would happen to the list as other people add new code slightly_smiling_face
right, makes sense. I guess you're not importing startable functions across modules (without using from grep
.
fixes #66 Branched from #68 - so the diff is a bit ugly. The manual test added should probably have a helper function.
I'm not entirely happy with the logic here, it now checks function names only against the last part of any specified pattern - which means that a startable function
foo
in modulebar
, that's only ever used in the code asbar.foo
, will never prompt you to add it if there's a pattern forother_module.foo
. Shared function names across modules/classes is pretty common, so means you can't relax and rely on TRIO114 to remind you every time you forget a method.Possible solutions:
zee.foo
check if we're in modulezee
, or we're a class method, otherwise error. If the pattern is justfoo
or*.foo
it's satisfied.foo
, and there's only one pattern specifying 'modulename.foo', be unhappy?Not super happy with either of those. Could maybe make it dumber and give a flag entering a verbose mode where it will print every time a positive match is made (instead of warning when there's no match) - meant to be inspected manually by the end-user every now and then. So e.g. prints
(TRIO113 could similarly also do that, to catch cases where modules are imported as aliases, or class methods are passed).