From 0d724cc8b8bf4c2034365bd088b2d19ccf28a957 Mon Sep 17 00:00:00 2001 From: Gil Forcada Codinachs Date: Wed, 2 Nov 2022 09:31:15 +0100 Subject: [PATCH 1/3] feat: support python 3.10 and 3.11 --- stdlib_list/base.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/stdlib_list/base.py b/stdlib_list/base.py index 0cde17a..4632fe3 100644 --- a/stdlib_list/base.py +++ b/stdlib_list/base.py @@ -10,10 +10,11 @@ from functools32 import lru_cache long_versions = ["2.6.9", "2.7.9", "3.2.6", "3.3.6", "3.4.3", "3.5", "3.6", - "3.7", "3.8", "3.9"] + "3.7", "3.8", "3.9", "3.10", "3.11"] short_versions = [".".join(x.split(".")[:2]) for x in long_versions] +builtin_versions = ["3.10", "3.11"] def get_canonical_version(version): @@ -42,11 +43,14 @@ def stdlib_list(version=None): version = get_canonical_version(version) if version is not None else '.'.join( str(x) for x in sys.version_info[:2]) - module_list_file = os.path.join("lists", "{}.txt".format(version)) + if version in builtin_versions: + result = list(set(list(sys.stdlib_module_names) + list(sys.builtin_module_names))) + else: + module_list_file = os.path.join("lists", "{}.txt".format(version)) - data = pkgutil.get_data("stdlib_list", module_list_file).decode() + data = pkgutil.get_data("stdlib_list", module_list_file).decode() - result = [y for y in [x.strip() for x in data.splitlines()] if y] + result = [y for y in [x.strip() for x in data.splitlines()] if y] return result From 796c658437febf522b4b8030cc353e574d850f7f Mon Sep 17 00:00:00 2001 From: Gil Forcada Codinachs Date: Wed, 2 Nov 2022 09:39:35 +0100 Subject: [PATCH 2/3] feat: add warning message --- stdlib_list/base.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stdlib_list/base.py b/stdlib_list/base.py index 4632fe3..cb41016 100644 --- a/stdlib_list/base.py +++ b/stdlib_list/base.py @@ -3,6 +3,7 @@ import os import pkgutil import sys +import warnings try: from functools import lru_cache @@ -15,6 +16,10 @@ short_versions = [".".join(x.split(".")[:2]) for x in long_versions] builtin_versions = ["3.10", "3.11"] +warning_message = ( + "This package is no longer needed to get Python stdlib modules on Python 3.10+." + "Python itself provides such list, see the one line on the README." +) def get_canonical_version(version): @@ -45,6 +50,8 @@ def stdlib_list(version=None): if version in builtin_versions: result = list(set(list(sys.stdlib_module_names) + list(sys.builtin_module_names))) + + warnings.warn(warning_message, DeprecationWarning) else: module_list_file = os.path.join("lists", "{}.txt".format(version)) From f50ee3f476bd87f557d24b81f7c29b92d4920008 Mon Sep 17 00:00:00 2001 From: Gil Forcada Codinachs Date: Wed, 2 Nov 2022 09:35:21 +0100 Subject: [PATCH 3/3] Add note on README about package status --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a4d7b99..bcf5246 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,13 @@ Python Standard Library List This package includes lists of all of the standard libraries for Python 2.6, 2.7, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, and 3.9 along with the code for scraping the official Python docs to get said lists. +Note: from Python 3.10 onwards one can use the following one-liner to get the list of available modules: + + >>> builtin_modules = list(set(list(sys.stdlib_module_names) + list(sys.builtin_module_names))) + +Thus, this package will not get any more updates. + + Listing the modules in the standard library? Wait, why on Earth would you care about that?! ------------------------------------------------------------------------------------------- @@ -21,4 +28,3 @@ Usage ['AL', 'BaseHTTPServer', 'Bastion', 'CGIHTTPServer', 'ColorPicker', 'ConfigParser', 'Cookie', 'DEVICE', 'DocXMLRPCServer', 'EasyDialogs'] For more details, check out [the docs](http://python-stdlib-list.readthedocs.org/en/latest/). -