这个问题是关于如何管理对其他私有 gitlab 包具有嵌套依赖关系的私有 gitlab python 包的访问。这假设所有访问都是通过直接 git 存储库模式而不是私有包存储库进行的。
package-a位于私有 gitlab 存储库中,它取决于package-b,这取决于package-c它们也位于私有 gitlab 存储库中。
package-a有pyproject.toml这样的:
[tool.poetry]
name = "package-a"
repository = "https://gitlab.com/org/package_a.git"
[tool.poetry.dependencies]
python = "^3.6"
package-b = {git = "ssh://git@gitlab.com/org/package_b.git", tag = "0.1.0"}
Run Code Online (Sandbox Code Playgroud)
package-b有pyproject.toml这样的:
[tool.poetry]
name = "package-b"
repository = "https://gitlab.com/org/package_b.git"
[tool.poetry.dependencies]
python = "^3.6"
package-c = {git = "ssh://git@gitlab.com/org/package_c.git", tag = "0.1.0"}
Run Code Online (Sandbox Code Playgroud)
任何org在 gitlab 上拥有正确成员资格和 ssh-key 的用户都可以poetry用来安装package-a,它依赖于package-b,然后依赖于package-c,所有这些都在开发笔记本电脑上的 python …
问题的明显解决方案是使用issubclass,但这会引发TypeError(使用 Python 3.6.7),例如
>>> from typing_extensions import Protocol
>>> class ProtoSubclass(Protocol):
... pass
...
>>> issubclass(ProtoSubclass, Protocol)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/conda/envs/airflow/lib/python3.6/site-packages/typing_extensions.py", line 1265, in __subclasscheck__
raise TypeError("Instance and class checks can only be used with"
TypeError: Instance and class checks can only be used with @runtime protocols
>>> from typing_extensions import runtime
>>> @runtime
... class ProtoSubclass(Protocol):
... pass
...
>>> issubclass(ProtoSubclass, Protocol)
Traceback (most recent call …Run Code Online (Sandbox Code Playgroud)