MCPcopy Create free account
hub / github.com/PyCQA/flake8 / _classify_plugins

Function _classify_plugins

src/flake8/plugins/finder.py:310–352  ·  view source on GitHub ↗
(
    plugins: list[LoadedPlugin],
    opts: PluginOptions,
)

Source from the content-addressed store, hash-verified

308
309
310def _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
355def load_plugins(

Callers 1

load_pluginsFunction · 0.85

Calls 3

ExecutionErrorClass · 0.90
PluginsClass · 0.85
CheckersClass · 0.85

Tested by

no test coverage detected