benkehoe / aws-assume-role-lib

Assumed role session chaining (with credential refreshing) for boto3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PEP-561 compliant package

kadrach opened this issue · comments

Just found this awesome utility that lets me make away with the cobbled-together solution I've been using for this purpose for ages 🥳

I noticed mypy complaining, yet this library appears to be mostly typed (specifically, the "user-facing" parts of it). Admittedly not very familiar with Python package distribution, but it appears that all is needed is inclusion of a "py.typed" marker file.

The patch below seems to make mypy happy and enables type checking for the functions exposed by this library.

From fbf622392c795189aca8638dc89f4d9970f5ebfb Mon Sep 17 00:00:00 2001
From: Niko Eckerskorn <neckers@amazon.com>
Date: Thu, 9 Sep 2021 14:31:24 +1000
Subject: [PATCH] Make package PEP-561 compliant

---
 aws_assume_role_lib.py => aws_assume_role_lib/__init__.py | 0
 aws_assume_role_lib/py.typed                              | 0
 pyproject.toml                                            | 3 +++
 3 files changed, 3 insertions(+)
 rename aws_assume_role_lib.py => aws_assume_role_lib/__init__.py (100%)
 create mode 100644 aws_assume_role_lib/py.typed

diff --git a/aws_assume_role_lib.py b/aws_assume_role_lib/__init__.py
similarity index 100%
rename from aws_assume_role_lib.py
rename to aws_assume_role_lib/__init__.py
diff --git a/aws_assume_role_lib/py.typed b/aws_assume_role_lib/py.typed
new file mode 100644
index 0000000..e69de29
diff --git a/pyproject.toml b/pyproject.toml
index 6bd6581..8149788 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -16,6 +16,9 @@ classifiers = [
     "Topic :: Utilities",
     "Topic :: Software Development :: Libraries"
 ]
+packages = [
+    { include = "aws_assume_role_lib" },
+]
 
 [tool.poetry.dependencies]
 python = "^3.6"
-- 
2.33.0

Is there a way to do this without ceasing to have this a single-file package? I don't want to rename the only file to __init__.py and make it less convenient to vendor in projects.

This PEP does not support distributing typing information as part of module-only distributions. The code should be refactored into a package-based distribution and indicate that the package supports typing as described above.

Reading the PEP, it unfortunately sounds like that is not supported.

I kept it as a single file inside the package, with the public members imported into __init__.py. See #6, released in v2.9