From a77f73dc27b8a090c2fbaa69cd92327f73bb925c Mon Sep 17 00:00:00 2001
From: William Woodruff <william@yossarian.net>
Date: Mon, 19 Jun 2023 23:32:48 -0400
Subject: [PATCH 1/5] reformat, lint, mypy hints

---
 .github/workflows/ci.yml | 18 +++++++++---------
 pyproject.toml           |  1 +
 stdlib_list/__init__.py  |  6 +++---
 stdlib_list/base.py      | 17 +++++++----------
 stdlib_list/py.typed     |  0
 tests/test_base.py       |  1 +
 6 files changed, 21 insertions(+), 22 deletions(-)
 create mode 100644 stdlib_list/py.typed

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 34cce10..b028755 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -29,12 +29,12 @@ jobs:
       - name: test
         run: make test INSTALL_EXTRA=test
 
-#   lint:
-#     runs-on: ubuntu-latest
-#     steps:
-#       - uses: actions/checkout@v3
-#       - uses: actions/setup-python@v4
-#         with:
-#           python-version: "3.10"
-#       - name: lint
-#         run: make lint INSTALL_EXTRA=lint
+  lint:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+      - uses: actions/setup-python@v4
+        with:
+          python-version: "3.x"
+      - name: lint
+        run: make lint INSTALL_EXTRA=lint
diff --git a/pyproject.toml b/pyproject.toml
index fb49c61..254b3aa 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -42,3 +42,4 @@ line-length = 100
 [tool.ruff]
 select = ["E", "F", "I", "W", "UP"]
 target-version = "py37"
+line-length = 100
diff --git a/stdlib_list/__init__.py b/stdlib_list/__init__.py
index ab610d9..41d9c9c 100644
--- a/stdlib_list/__init__.py
+++ b/stdlib_list/__init__.py
@@ -2,11 +2,11 @@
 
 # Import all the things that used to be in here for backwards-compatibility reasons
 from .base import (
-    stdlib_list,
-    in_stdlib,
     get_canonical_version,
-    short_versions,
+    in_stdlib,
     long_versions,
+    short_versions,
+    stdlib_list,
 )
 
 __all__ = [
diff --git a/stdlib_list/base.py b/stdlib_list/base.py
index 75aa30b..bf810cd 100644
--- a/stdlib_list/base.py
+++ b/stdlib_list/base.py
@@ -1,9 +1,6 @@
-from __future__ import print_function, absolute_import
-
 import os
 import pkgutil
 import sys
-
 from functools import lru_cache
 
 long_versions = [
@@ -24,16 +21,16 @@
 short_versions = [".".join(x.split(".")[:2]) for x in long_versions]
 
 
-def get_canonical_version(version):
+def get_canonical_version(version: str) -> str:
     if version in long_versions:
         version = ".".join(version.split(".")[:2])
     elif version not in short_versions:
-        raise ValueError("No such version: {}".format(version))
+        raise ValueError(f"No such version: {version}")
 
     return version
 
 
-def stdlib_list(version=None):
+def stdlib_list(version: str | None = None) -> list[str]:
     """
     Given a ``version``, return a ``list`` of names of the Python Standard
     Libraries for that version.
@@ -53,9 +50,9 @@ def stdlib_list(version=None):
         else ".".join(str(x) for x in sys.version_info[:2])
     )
 
-    module_list_file = os.path.join("lists", "{}.txt".format(version))
+    module_list_file = os.path.join("lists", f"{version}.txt")
 
-    data = pkgutil.get_data("stdlib_list", module_list_file).decode()
+    data = pkgutil.get_data("stdlib_list", module_list_file).decode()  # type: ignore[union-attr]
 
     result = [y for y in [x.strip() for x in data.splitlines()] if y]
 
@@ -63,13 +60,13 @@ def stdlib_list(version=None):
 
 
 @lru_cache(maxsize=16)
-def _stdlib_list_with_cache(version=None):
+def _stdlib_list_with_cache(version: str | None = None) -> list[str]:
     """Internal cached version of `stdlib_list`"""
     return stdlib_list(version=version)
 
 
 @lru_cache(maxsize=256)
-def in_stdlib(module_name, version=None):
+def in_stdlib(module_name: str, version: str | None = None) -> bool:
     """
     Return a ``bool`` indicating if module ``module_name`` is in the list of stdlib
     symbols for python version ``version``. If ``version`` is ``None`` (default), the
diff --git a/stdlib_list/py.typed b/stdlib_list/py.typed
new file mode 100644
index 0000000..e69de29
diff --git a/tests/test_base.py b/tests/test_base.py
index 89fbc71..cebd04b 100644
--- a/tests/test_base.py
+++ b/tests/test_base.py
@@ -1,4 +1,5 @@
 import pkgutil
+
 import pytest
 
 import stdlib_list

From 2d6584d860d61bf93a64022e7f42c27d819f9b89 Mon Sep 17 00:00:00 2001
From: William Woodruff <william@yossarian.net>
Date: Mon, 19 Jun 2023 23:33:49 -0400
Subject: [PATCH 2/5] pyproject: strong mypy config

---
 pyproject.toml | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/pyproject.toml b/pyproject.toml
index 254b3aa..c2d70da 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -35,6 +35,22 @@ dev = ["build", "stdlib-list[test,lint,doc]"]
 # CI only: used for list generation for Python versions < 3.10.
 support = ["sphobjinv"]
 
+[tool.mypy]
+allow_redefinition = true
+check_untyped_defs = true
+disallow_incomplete_defs = true
+disallow_untyped_defs = true
+ignore_missing_imports = true
+no_implicit_optional = true
+show_error_codes = true
+sqlite_cache = true
+strict_equality = true
+warn_no_return = true
+warn_redundant_casts = true
+warn_return_any = true
+warn_unreachable = true
+warn_unused_configs = true
+warn_unused_ignores = true
 
 [tool.black]
 line-length = 100

From 0a304082da0fdb2db0c7cbb7129b31a32ac7ee3e Mon Sep 17 00:00:00 2001
From: William Woodruff <william@yossarian.net>
Date: Mon, 19 Jun 2023 23:36:08 -0400
Subject: [PATCH 3/5] base: __future__

---
 stdlib_list/base.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/stdlib_list/base.py b/stdlib_list/base.py
index bf810cd..b7a4152 100644
--- a/stdlib_list/base.py
+++ b/stdlib_list/base.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
 import os
 import pkgutil
 import sys

From 1d0a65fece0525bb99d2f1afdcd7a89b542e35ab Mon Sep 17 00:00:00 2001
From: William Woodruff <william@yossarian.net>
Date: Mon, 19 Jun 2023 23:46:14 -0400
Subject: [PATCH 4/5] cleanup docs, make consistent, use furo

More misc cleanup.
---
 README.md      |  5 ++---
 docs/conf.py   |  7 +++----
 docs/index.rst | 24 +++++++++---------------
 pyproject.toml |  2 +-
 4 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/README.md b/README.md
index 4563eb3..b06fbbc 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,7 @@
 # stdlib-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.
+This package includes lists of all of the standard libraries for Python 2.6
+through 3.11.
 
 **IMPORTANT**: If you're on Python 3.10 or newer, you **probably don't need this library**.
 See [`sys.stdlib_module_names`](https://docs.python.org/3/library/sys.html#sys.stdlib_module_names)
diff --git a/docs/conf.py b/docs/conf.py
index cfb6c26..6ac7d2b 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -30,10 +30,9 @@
 extensions = [
     "sphinx.ext.autodoc",
     "sphinx.ext.viewcode",
-    "sphinx_rtd_theme",
 ]
 
-html_theme = "sphinx_rtd_theme"
+html_theme = "furo"
 
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ["_templates"]
@@ -48,8 +47,8 @@
 master_doc = "index"
 
 # General information about the project.
-project = "Python Standard Library List"
-copyright = "2015, Jack Maney"
+project = "stdlib-list"
+copyright = "2015, stdlib-list authors"
 
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the
diff --git a/docs/index.rst b/docs/index.rst
index 5421028..fbbf94b 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -1,21 +1,15 @@
-.. Python Standard Library List documentation master file, created by
-   sphinx-quickstart on Tue Mar 10 02:16:08 2015.
-   You can adapt this file completely to your liking, but it should at least
-   contain the root `toctree` directive.
+stdlib-list
+===========
 
-Python Standard Library List
-========================================================
+This package includes lists of all of the standard libraries for Python 2.6
+through 3.11.
 
-This package includes lists of all of the standard libraries for Python 2.6, 2.7, 3.2, 3.3, and 3.4, along with the code for scraping the official Python docs to get said lists.
+.. note::
 
-Listing the modules in the standard library? Wait, why on Earth would you care about that?!
-===========================================================================================
-
-Because knowing whether or not a module is part of the standard library will come in handy in `a project of mine <https://github.com/jackmaney/pypt>`_. `And I'm not the only one <http://stackoverflow.com/questions/6463918/how-can-i-get-a-list-of-all-the-python-standard-library-modules>`_ who would find this useful. Or, the TL;DR answer is that it's handy in situations when you're analyzing Python code and would like to find module dependencies.
-
-After googling for a way to generate a list of Python standard libraries (and looking through the answers to the previously-linked Stack Overflow question), I decided that I didn't like the existing solutions. So, I started by writing a scraper for the TOC of the Python Module Index for each of the versions of Python above.
-
-However, web scraping can be a fragile affair. Thanks to `a suggestion <https://github.com/jackmaney/python-stdlib-list/issues/1#issuecomment-86517208>`_ by `@ncoghlan <https://github.com/ncoghlan>`_, and some further help from `@birkenfeld <https://github.com/birkenfeld>`_ and `@epc <https://github.com/epc>`_, the population of the lists is now done by grabbing and parsing the Sphinx object inventory for the official Python docs of each relevant version.
+   If you're on Python 3.10 or newer, you **probably don't need this library**.
+   See `sys.stdlib_module_names <https://docs.python.org/3/library/sys.html#sys.stdlib_module_names>`_
+   and `sys.builtin_module_names <https://docs.python.org/3/library/sys.html#sys.builtin_module_names>`_
+   for similar functionality.
 
 Contents
 ========
diff --git a/pyproject.toml b/pyproject.toml
index c2d70da..f5ca44b 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -30,7 +30,7 @@ Source = "https://github.com/pypi/stdlib-list"
 [project.optional-dependencies]
 test = ["pytest", "pytest-cov", "coverage[toml]"]
 lint = ["black", "mypy", "ruff"]
-doc = ["sphinx", "sphinx_rtd_theme"]
+doc = ["sphinx", "furo"]
 dev = ["build", "stdlib-list[test,lint,doc]"]
 # CI only: used for list generation for Python versions < 3.10.
 support = ["sphobjinv"]

From ecbe36996e9ac63d49c51768906174183b99c2a3 Mon Sep 17 00:00:00 2001
From: William Woodruff <william@yossarian.net>
Date: Tue, 20 Jun 2023 00:24:55 -0400
Subject: [PATCH 5/5] workflows: add release workflow

---
 .github/workflows/release.yml | 42 +++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 .github/workflows/release.yml

diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..705510d
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,42 @@
+on:
+  release:
+    types:
+      - published
+
+name: release
+
+jobs:
+  pypi:
+    name: upload release to PyPI
+    runs-on: ubuntu-latest
+    environment: release
+    permissions:
+      # Used for OIDC publishing.
+      # Used to sign the release's artifacts with sigstore-python.
+      id-token: write
+
+      # Used to attach signing artifacts to the published release.
+      contents: write
+
+    steps:
+    - uses: actions/checkout@v3
+
+    - uses: actions/setup-python@v4
+      with:
+        python-version: "3.x"
+
+    - name: deps
+      run: python -m pip install -U setuptools build wheel
+
+    - name: build
+      run: python -m build
+
+    - name: publish
+      uses: pypa/gh-action-pypi-publish@v1.8.6
+
+    - name: sign
+      uses: sigstore/gh-action-sigstore-python@v1.2.3
+      with:
+        inputs: ./dist/*.tar.gz ./dist/*.whl
+        release-signing-artifacts: true
+        bundle-only: true