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

Class StyleGuide

src/flake8/api/legacy.py:68–190  ·  view source on GitHub ↗

Public facing object that mimic's Flake8 2.0's StyleGuide. .. note:: There are important changes in how this object behaves compared to the StyleGuide object provided in Flake8 2.x. .. warning:: This object should not be instantiated directly by users. .. ver

Source from the content-addressed store, hash-verified

66
67
68class StyleGuide:
69 """Public facing object that mimic's Flake8 2.0's StyleGuide.
70
71 .. note::
72
73 There are important changes in how this object behaves compared to
74 the StyleGuide object provided in Flake8 2.x.
75
76 .. warning::
77
78 This object should not be instantiated directly by users.
79
80 .. versionchanged:: 3.0.0
81 """
82
83 def __init__(self, application: app.Application) -> None:
84 """Initialize our StyleGuide."""
85 self._application = application
86 self._file_checker_manager = application.file_checker_manager
87
88 @property
89 def options(self) -> argparse.Namespace:
90 """Return application's options.
91
92 An instance of :class:`argparse.Namespace` containing parsed options.
93 """
94 assert self._application.options is not None
95 return self._application.options
96
97 @property
98 def paths(self) -> list[str]:
99 """Return the extra arguments passed as paths."""
100 assert self._application.options is not None
101 return self._application.options.filenames
102
103 def check_files(self, paths: list[str] | None = None) -> Report:
104 """Run collected checks on the files provided.
105
106 This will check the files passed in and return a :class:`Report`
107 instance.
108
109 :param paths:
110 List of filenames (or paths) to check.
111 :returns:
112 Object that mimic's Flake8 2.0's Reporter class.
113 """
114 assert self._application.options is not None
115 self._application.options.filenames = paths
116 self._application.run_checks()
117 self._application.report_errors()
118 return Report(self._application)
119
120 def excluded(self, filename: str, parent: str | None = None) -> bool:
121 """Determine if a file is excluded.
122
123 :param filename:
124 Path to the file to check if it is excluded.
125 :param parent:

Callers 1

get_style_guideFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected