Skip to content

Commit

Permalink
Rewrite 'yarl' module name for exposed public API functions
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Jul 26, 2020
1 parent cc8cf7b commit 3ecfc65
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions yarl/_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1075,18 +1081,21 @@ 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(),
"idna_decode": _idna_decode.cache_info(),
}


@rewrite_module
def cache_configure(*, idna_encode_size=_MAXCACHE, idna_decode_size=_MAXCACHE):
global _idna_decode, _idna_encode

Expand Down

0 comments on commit 3ecfc65

Please sign in to comment.