You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just started trying to write a check plugin for Flake8, and nowhere in the docs could I find an example of what the plugin should look like. The docs mention add_options and parse_options, but do not show where to put them.
Should my plugin inherit from a base class?
Should it declare some attributes?
What methods should I implement?
OK, at this point I just searched for a recent plugin to see how it's written.
It would be nice if the docs showed a minimal example, something like this:
I found a simpler case that is possible using just a function. This one operates on physical lines, so the expected returned items are just (text_offset_into_line, error_message)
defno_bare_typing_import(physical_line):
ifphysical_line=='import typing\n':
return [(0, "XXX001 'import typing' found, use 'from typing import ...' ""instead for shorter type signatures")]
no_bare_typing_import.name=no_bare_typing_import.__name__no_bare_typing_import.version='1.0'
Activity
asottile commentedon Apr 3, 2021
In GitLab by @sigmavirus24 on Jan 18, 2017, 05:09
Would you prefer more examples of plugins or just an interface definition that plugins need to satisfy?
asottile commentedon Apr 3, 2021
In GitLab by @graingert on Jan 18, 2017, 05:29
Now that you've given me the option, I'd like both :D
asottile commentedon Apr 3, 2021
In GitLab by @sigmavirus24 on Jan 21, 2017, 05:32
@graingert then I expect you to do the review on the pull request that will be made for this. ;)
asottile commentedon Apr 3, 2021
In GitLab by @graingert on Jan 22, 2017, 03:34
Sure. If you can provide a mypy abc that would be even better
asottile commentedon Apr 3, 2021
In GitLab by @pawamoy on Jun 18, 2020, 07:17
+1!
I just started trying to write a check plugin for Flake8, and nowhere in the docs could I find an example of what the plugin should look like. The docs mention
add_optionsandparse_options, but do not show where to put them.OK, at this point I just searched for a recent plugin to see how it's written.
It would be nice if the docs showed a minimal example, something like this:
asottile commentedon Apr 3, 2021
In GitLab by @asottile on Jun 18, 2020, 09:17
fwiw, I threw together a youtube video about making a plugin that might be helpful
asottile commentedon Apr 3, 2021
In GitLab by @pawamoy on Jun 18, 2020, 09:56
Thanks, I love
astpretty, I wish I knew it before!asottile commentedon Apr 3, 2021
In GitLab by @spookylukey on Dec 21, 2020, 02:50
Thanks @pawamoy that's really helpful.
I found a simpler case that is possible using just a function. This one operates on physical lines, so the expected returned items are just
(text_offset_into_line, error_message)