Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions mypy/stubtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ def verify_mypyfile(
if isinstance(runtime, Missing):
yield Error(object_path, "is not present at runtime", stub, runtime)
return

# Workaround for pyOpenSSL that has its module objects wrapped.
# See https://github.com/python/typeshed/pull/5657 for details.
if f"{type(runtime).__module__}.{type(runtime).__qualname__}" \
== "cryptography.utils._ModuleWithDeprecations":
runtime = runtime._module # type: ignore[attr-defined]

if not isinstance(runtime, types.ModuleType):
yield Error(object_path, "is not a module", stub, runtime)
return
Expand Down Expand Up @@ -652,6 +659,12 @@ def verify_funcitem(
yield Error(object_path, "is not present at runtime", stub, runtime)
return

# Workaround for pyOpenSSL that has some of its function objects wrapped.
# See https://github.com/python/typeshed/pull/5657 for details.
if f"{type(runtime).__module__}.{type(runtime).__qualname__}" \
== "cryptography.utils._DeprecatedValue":
runtime = runtime.value

if (
not isinstance(runtime, (types.FunctionType, types.BuiltinFunctionType))
and not isinstance(runtime, (types.MethodType, types.BuiltinMethodType))
Expand Down