Skip to content

Commit

Permalink
Removed dependency on isort (#140)
Browse files Browse the repository at this point in the history
* Removed dependency on isort
* updated script to generate stdlibs
Co-authored-by: Mathieu Kniewallner <[email protected]>
  • Loading branch information
fpgmaas authored Sep 30, 2022
1 parent 94c731e commit b45c8f5
Show file tree
Hide file tree
Showing 9 changed files with 1,331 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
docs/source
deptry.json

.DS_Store

# From https://raw.githubusercontent.com/github/gitignore/main/Python.gitignore

Byte-compiled / optimized / DLL files
Expand Down
16 changes: 5 additions & 11 deletions deptry/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
from pathlib import Path
from typing import List, Optional, Set

from isort.stdlibs.py37 import stdlib as stdlib37
from isort.stdlibs.py38 import stdlib as stdlib38
from isort.stdlibs.py39 import stdlib as stdlib39
from isort.stdlibs.py310 import stdlib as stdlib310

from deptry.compat import PackageNotFoundError, metadata
from deptry.dependency import Dependency

Expand Down Expand Up @@ -123,20 +118,19 @@ def _in_standard_library(self) -> bool:

def _get_stdlib_packages(self) -> Set[str]:
incorrect_version_error = ValueError(
f"Incorrect Python version {'.'.join([str(x) for x in sys.version_info[0:3]])}. Only 3.7, 3.8, 3.9 and 3.10 are currently supported."
f"Incorrect Python version {'.'.join([str(x) for x in sys.version_info[0:3]])}. Only 3.7, 3.8, 3.9, and 3.10 are currently supported."
)
if sys.version_info[0] == 3:
if sys.version_info[1] == 7:
stdlib = stdlib37
from deptry.stdlibs.py37 import stdlib
elif sys.version_info[1] == 8:
stdlib = stdlib38
from deptry.stdlibs.py38 import stdlib
elif sys.version_info[1] == 9:
stdlib = stdlib39
from deptry.stdlibs.py39 import stdlib
elif sys.version_info[1] == 10:
stdlib = stdlib310
from deptry.stdlibs.py310 import stdlib
else:
raise incorrect_version_error
stdlib.add("__future__") # Not sure why this is omitted explicitly in isort's source code.
return stdlib
else:
raise incorrect_version_error
Expand Down
222 changes: 222 additions & 0 deletions deptry/stdlibs/py310.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
"""
DO NOT EDIT THIS FILE MANUALLY.
It is generated from `scripts/generate_stdlibs.py` script and contains the stdlib modules for Python 3.10.
You can generate it again using `poetry run scripts/generate_stdlibs.py`.
"""

stdlib = {
"__future__",
"_ast",
"_thread",
"abc",
"aifc",
"argparse",
"array",
"ast",
"asynchat",
"asyncio",
"asyncore",
"atexit",
"audioop",
"base64",
"bdb",
"binascii",
"binhex",
"bisect",
"builtins",
"bz2",
"cProfile",
"calendar",
"cgi",
"cgitb",
"chunk",
"cmath",
"cmd",
"code",
"codecs",
"codeop",
"collections",
"colorsys",
"compileall",
"concurrent",
"configparser",
"contextlib",
"contextvars",
"copy",
"copyreg",
"crypt",
"csv",
"ctypes",
"curses",
"dataclasses",
"datetime",
"dbm",
"decimal",
"difflib",
"dis",
"distutils",
"doctest",
"email",
"encodings",
"ensurepip",
"enum",
"errno",
"faulthandler",
"fcntl",
"filecmp",
"fileinput",
"fnmatch",
"fractions",
"ftplib",
"functools",
"gc",
"getopt",
"getpass",
"gettext",
"glob",
"graphlib",
"grp",
"gzip",
"hashlib",
"heapq",
"hmac",
"html",
"http",
"idlelib",
"imaplib",
"imghdr",
"imp",
"importlib",
"inspect",
"io",
"ipaddress",
"itertools",
"json",
"keyword",
"lib2to3",
"linecache",
"locale",
"logging",
"lzma",
"mailbox",
"mailcap",
"marshal",
"math",
"mimetypes",
"mmap",
"modulefinder",
"msilib",
"msvcrt",
"multiprocessing",
"netrc",
"nis",
"nntplib",
"ntpath",
"numbers",
"operator",
"optparse",
"os",
"ossaudiodev",
"pathlib",
"pdb",
"pickle",
"pickletools",
"pipes",
"pkgutil",
"platform",
"plistlib",
"poplib",
"posix",
"posixpath",
"pprint",
"profile",
"pstats",
"pty",
"pwd",
"py_compile",
"pyclbr",
"pydoc",
"queue",
"quopri",
"random",
"re",
"readline",
"reprlib",
"resource",
"rlcompleter",
"runpy",
"sched",
"secrets",
"select",
"selectors",
"shelve",
"shlex",
"shutil",
"signal",
"site",
"smtpd",
"smtplib",
"sndhdr",
"socket",
"socketserver",
"spwd",
"sqlite3",
"sre",
"sre_compile",
"sre_constants",
"sre_parse",
"ssl",
"stat",
"statistics",
"string",
"stringprep",
"struct",
"subprocess",
"sunau",
"symtable",
"sys",
"sysconfig",
"syslog",
"tabnanny",
"tarfile",
"telnetlib",
"tempfile",
"termios",
"test",
"textwrap",
"threading",
"time",
"timeit",
"tkinter",
"token",
"tokenize",
"trace",
"traceback",
"tracemalloc",
"tty",
"turtle",
"turtledemo",
"types",
"typing",
"unicodedata",
"unittest",
"urllib",
"uu",
"uuid",
"venv",
"warnings",
"wave",
"weakref",
"webbrowser",
"winreg",
"winsound",
"wsgiref",
"xdrlib",
"xml",
"xmlrpc",
"zipapp",
"zipfile",
"zipimport",
"zlib",
"zoneinfo",
}
Loading

0 comments on commit b45c8f5

Please sign in to comment.