125 # don't do anything, if no codes were selected |
129 # don't do anything, if no codes were selected |
126 return |
130 return |
127 |
131 |
128 for check in self.__checkers: |
132 for check in self.__checkers: |
129 check() |
133 check() |
|
134 |
|
135 def getStandardModules(self): |
|
136 """ |
|
137 Public method to get a list of modules of the standard library. |
|
138 |
|
139 @return set of builtin modules |
|
140 @rtype set of str |
|
141 """ |
|
142 try: |
|
143 return sys.stdlib_module_names |
|
144 except AttributeError: |
|
145 return { |
|
146 "__future__", "__main__", "_dummy_thread", "_thread", "abc", |
|
147 "aifc", "argparse", "array", "ast", "asynchat", "asyncio", |
|
148 "asyncore", "atexit", "audioop", "base64", "bdb", "binascii", |
|
149 "binhex", "bisect", "builtins", "bz2", "calendar", "cgi", |
|
150 "cgitb", "chunk", "cmath", "cmd", "code", "codecs", "codeop", |
|
151 "collections", "colorsys", "compileall", "concurrent", |
|
152 "configparser", "contextlib", "contextvars", "copy", "copyreg", |
|
153 "cProfile", "crypt", "csv", "ctypes", "curses", "dataclasses", |
|
154 "datetime", "dbm", "decimal", "difflib", "dis", "distutils", |
|
155 "doctest", "dummy_threading", "email", "encodings", |
|
156 "ensurepip", "enum", "errno", "faulthandler", "fcntl", |
|
157 "filecmp", "fileinput", "fnmatch", "formatter", "fractions", |
|
158 "ftplib", "functools", "gc", "getopt", "getpass", "gettext", |
|
159 "glob", "grp", "gzip", "hashlib", "heapq", "hmac", "html", |
|
160 "http", "imaplib", "imghdr", "imp", "importlib", "inspect", |
|
161 "io", "ipaddress", "itertools", "json", "keyword", "lib2to3", |
|
162 "linecache", "locale", "logging", "lzma", "mailbox", "mailcap", |
|
163 "marshal", "math", "mimetypes", "mmap", "modulefinder", |
|
164 "msilib", "msvcrt", "multiprocessing", "netrc", "nis", |
|
165 "nntplib", "numbers", "operator", "optparse", "os", |
|
166 "ossaudiodev", "parser", "pathlib", "pdb", "pickle", |
|
167 "pickletools", "pipes", "pkgutil", "platform", "plistlib", |
|
168 "poplib", "posix", "pprint", "profile", "pstats", "pty", "pwd", |
|
169 "py_compile", "pyclbr", "pydoc", "queue", "quopri", "random", |
|
170 "re", "readline", "reprlib", "resource", "rlcompleter", |
|
171 "runpy", "sched", "secrets", "select", "selectors", "shelve", |
|
172 "shlex", "shutil", "signal", "site", "smtpd", "smtplib", |
|
173 "sndhdr", "socket", "socketserver", "spwd", "sqlite3", "ssl", |
|
174 "stat", "statistics", "string", "stringprep", "struct", |
|
175 "subprocess", "sunau", "symbol", "symtable", "sys", |
|
176 "sysconfig", "syslog", "tabnanny", "tarfile", "telnetlib", |
|
177 "tempfile", "termios", "test", "textwrap", "threading", "time", |
|
178 "timeit", "tkinter", "token", "tokenize", "trace", "traceback", |
|
179 "tracemalloc", "tty", "turtle", "turtledemo", "types", |
|
180 "typing", "unicodedata", "unittest", "urllib", "uu", "uuid", |
|
181 "venv", "warnings", "wave", "weakref", "webbrowser", "winreg", |
|
182 "winsound", "wsgiref", "xdrlib", "xml", "xmlrpc", "zipapp", |
|
183 "zipfile", "zipimport", "zlib", "zoneinfo", |
|
184 } |
|
185 |
|
186 ####################################################################### |
|
187 ## Local imports |
|
188 ## |
|
189 ## adapted from: flake8-local-import v1.0.6 |
|
190 ####################################################################### |
|
191 |
|
192 def __checkLocalImports(self): |
|
193 """ |
|
194 Private method to check local imports. |
|
195 """ |
|
196 from .LocalImportVisitor import LocalImportVisitor |
|
197 |
|
198 visitor = LocalImportVisitor(self.__args, self) |
|
199 visitor.visit(copy.deepcopy(self.__tree)) |
|
200 for violation in visitor.violations: |
|
201 node = violation[0] |
|
202 reason = violation[1] |
|
203 self.__error(node.lineno - 1, node.col_offset, reason) |