From 3ecfc65d776895f02a2cb72623ba79732ce700c7 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Sun, 26 Jul 2020 10:35:40 +0300 Subject: [PATCH] Rewrite 'yarl' module name for exposed public API functions --- yarl/_url.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/yarl/_url.py b/yarl/_url.py index c9f65ceef..74d0dbd2a 100644 --- a/yarl/_url.py +++ b/yarl/_url.py @@ -17,6 +17,11 @@ sentinel = object() +def rewrite_module(obj: object) -> object: + obj.__module__ = "yarl" + return obj + + class cached_property: """Use as a class method decorator. It operates almost exactly like the Python `@property` decorator, but it puts the result of the @@ -48,6 +53,7 @@ def __set__(self, inst, value): raise AttributeError("cached property is read-only") +@rewrite_module class URL: # Don't derive from str # follow pathlib.Path design @@ -1075,11 +1081,13 @@ def _idna_encode(host): return host.encode("idna").decode("ascii") +@rewrite_module def cache_clear(): _idna_decode.cache_clear() _idna_encode.cache_clear() +@rewrite_module def cache_info(): return { "idna_encode": _idna_encode.cache_info(), @@ -1087,6 +1095,7 @@ def cache_info(): } +@rewrite_module def cache_configure(*, idna_encode_size=_MAXCACHE, idna_decode_size=_MAXCACHE): global _idna_decode, _idna_encode