Repository: pradyunsg/vendoring (language: python)

Issue:
Typing stub should not be generated for libraries with typing support
Resolvelib 0.6.0 started carrying its own type stubs, but vendoring still generates a `resolvelib.pyi`. This seems to cause issues—not exactly sure about the cause.

I think vendoring can detect whether the vendored package contains a `py.typed` file and skip stub generation.


Discussion / hints:
For now, you can specify an empty list for the package in the stubs table, which should allow dealing with this situation.

Fix patch:
diff --git a/src/vendoring/tasks/stubs.py b/src/vendoring/tasks/stubs.py
index d6b509e..8660cf0 100644
--- a/src/vendoring/tasks/stubs.py
+++ b/src/vendoring/tasks/stubs.py
@@ -46,5 +46,7 @@ def generate_stubs(config: Configuration, libraries: List[str]) -> None:
 
     for lib in libraries:
         for rel_location, import_name in determine_stub_files(lib, typing_stubs):
+            if (destination / lib / "py.typed").is_file():  # Already have types.
+                continue
             stub_location = destination / rel_location
             write_stub(stub_location, import_name)


Test patch:
diff --git a/tests/test_sample_projects.py b/tests/test_sample_projects.py
index da870dc..f1f38df 100644
--- a/tests/test_sample_projects.py
+++ b/tests/test_sample_projects.py
@@ -36,10 +36,7 @@ def test_basic(tmp_path, monkeypatch):
 
     vendored = tmp_path / "vendored"
     assert vendored.exists()
-    assert sorted(os.listdir(vendored)) == [
-        "packaging",
-        "packaging.pyi",
-    ]
+    assert sorted(os.listdir(vendored)) == ["packaging"]
 
     packaging = vendored / "packaging"
     assert packaging.exists()
@@ -140,11 +137,7 @@ def test_protected_files(tmp_path, monkeypatch):
 
     vendored = tmp_path / "vendored"
     assert vendored.exists()
-    assert sorted(os.listdir(vendored)) == [
-        "README.md",
-        "packaging",
-        "packaging.pyi",
-    ]
+    assert sorted(os.listdir(vendored)) == ["README.md", "packaging"]
 
 
 def test_transformations(tmp_path, monkeypatch):