(
plugins: list[LoadedPlugin],
opts: PluginOptions,
)
| 308 | |
| 309 | |
| 310 | def _classify_plugins( |
| 311 | plugins: list[LoadedPlugin], |
| 312 | opts: PluginOptions, |
| 313 | ) -> Plugins: |
| 314 | tree = [] |
| 315 | logical_line = [] |
| 316 | physical_line = [] |
| 317 | reporters = {} |
| 318 | disabled = [] |
| 319 | |
| 320 | for loaded in plugins: |
| 321 | if ( |
| 322 | getattr(loaded.obj, "off_by_default", False) |
| 323 | and loaded.plugin.entry_point.name not in opts.enable_extensions |
| 324 | ): |
| 325 | disabled.append(loaded) |
| 326 | elif loaded.plugin.entry_point.group == "flake8.report": |
| 327 | reporters[loaded.entry_name] = loaded |
| 328 | elif "tree" in loaded.parameters: |
| 329 | tree.append(loaded) |
| 330 | elif "logical_line" in loaded.parameters: |
| 331 | logical_line.append(loaded) |
| 332 | elif "physical_line" in loaded.parameters: |
| 333 | physical_line.append(loaded) |
| 334 | else: |
| 335 | raise NotImplementedError(f"what plugin type? {loaded}") |
| 336 | |
| 337 | for loaded in itertools.chain(tree, logical_line, physical_line): |
| 338 | if not VALID_CODE_PREFIX.match(loaded.entry_name): |
| 339 | raise ExecutionError( |
| 340 | f"plugin code for `{loaded.display_name}` does not match " |
| 341 | f"{VALID_CODE_PREFIX.pattern}", |
| 342 | ) |
| 343 | |
| 344 | return Plugins( |
| 345 | checkers=Checkers( |
| 346 | tree=tree, |
| 347 | logical_line=logical_line, |
| 348 | physical_line=physical_line, |
| 349 | ), |
| 350 | reporters=reporters, |
| 351 | disabled=disabled, |
| 352 | ) |
| 353 | |
| 354 | |
| 355 | def load_plugins( |
no test coverage detected