Skip to content

Commit

Permalink
builtins: Clarify docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
laurensvalk committed Aug 2, 2021
1 parent ac826f8 commit 01ae6d0
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/ubuiltins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,32 @@ def __init__(self) -> None:
...

@overload
def __init__(self, source: Union[_int, _bytes, Iterable[_int]]) -> None:
def __init__(self, source: _int) -> None:
...

@overload
def __init__(self, source: _str, encoding: _str) -> None:
def __init__(self, source: Union[_bytes, _bytearray, Iterable[_int]]) -> None:
...

@overload
def __init__(self, source: _str, encoding: _str, errors: _str) -> None:
def __init__(self, source: _str, encoding: _str) -> None:
...

def __init__(self, *args):
"""
Returns a new ``bytes`` object, which is an immutable sequence of integers
in the range ``0 <= x <= 255``.
Creates a new ``bytes`` object, which is a sequence of integers
in the range :math:`0 \leq x \leq 255`. This object is *immutable*,
which means that you *cannot* change its contents after you create it.
* If no argument is given, this creates an empty ``bytes`` object.
* If the ``source`` argument is an integer, this creates a ``bytes``
object of zeros. The argument specifies how many zeros.
* If ``source`` is a ``bytearray``, ``bytes`` object, or some other
iterable of integers, this creates a ``bytes``
object with the same byte sequence as the ``source`` argument.
* If ``source`` is a string, choose ``'utf8'`` as the ``encoding``
argument. Then this creates a ``bytes`` object containing the
encoded string.
"""


Expand All @@ -160,8 +171,8 @@ def __init__(self, source: Union[_bytes, _bytearray, _str, Iterable[_int]]) -> N
def __init__(self, *args):
"""
Creates a new ``bytearray`` object, which is a sequence of integers
in the range ``0 <= x <= 255``. This object is mutable, which means
that you can change its contents after you create it.
in the range :math:`0 \leq x \leq 255`. This object is *mutable*, which
means that you *can* change its contents after you create it.
* If no argument is given, this creates an empty ``bytearray``.
* If the ``source`` argument is an integer, this creates a ``bytearray``
Expand Down

0 comments on commit 01ae6d0

Please sign in to comment.