Skip to content

Commit 87a2fca

Browse files
authored
Fix typos and grammar in writing stubs guide i.e writing_stubs.rst (#2290)
1 parent 187c90b commit 87a2fca

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

docs/guides/writing_stubs.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ Attribute Access
276276

277277
Python has several methods for customizing attribute access: ``__getattr__``,
278278
``__getattribute__``, ``__setattr__``, and ``__delattr__``. Of these,
279-
``__getattr__`` and ``__setattr___`` should sometimes be included in stubs.
279+
``__getattr__`` and ``__setattr__`` should sometimes be included in stubs.
280280

281281
In addition to marking incomplete definitions, ``__getattr__`` should be
282282
included when a class or module allows any name to be accessed. For example, consider
@@ -316,7 +316,7 @@ In this case, the stub should list the attributes individually::
316316
def imag(self) -> float: ...
317317
def __init__(self, n: complex) -> None: ...
318318

319-
``__setattr___`` should be included when a class allows any name to be set and
319+
``__setattr__`` should be included when a class allows any name to be set and
320320
restricts the type. For example::
321321

322322
class IntHolder:
@@ -478,7 +478,7 @@ this, we need an extra overload::
478478
As before, the first overload is picked when the mode is ``"r"`` or not given.
479479
Otherwise, the second overload is used when ``open`` is called with an explicit
480480
``name``, e.g. ``open("file.txt", "w")`` or ``open(None, "w")``. The third
481-
overload is used when ``open`` is called without a name , e.g.
481+
overload is used when ``open`` is called without a name, e.g.
482482
``open(mode="w")``.
483483

484484
Style Guide
@@ -790,7 +790,7 @@ reasons can include:
790790
* Using :ref:`Any` as a type argument for a generic with invariant type variables
791791
to say "any object of this type is allowed", e.g. ``Future[Any]``.
792792
* Using ``dict[str, Any]`` or ``Mapping[str, Any]`` when the value types
793-
depends on the keys. But consider using :ref:`TypedDict` or
793+
depend on the keys. But consider using :ref:`TypedDict` or
794794
``dict[str, Incomplete]`` (temporarily) when the keys of the dictionary are
795795
fixed.
796796

@@ -806,16 +806,16 @@ Consider the following (simplified) signature of ``re.Match[str].group``::
806806
class Match:
807807
def group(self, group: str | int, /) -> str | MaybeNone: ...
808808

809-
This avoid forcing the user to check for ``None``::
809+
This avoids forcing the user to check for ``None``::
810810

811811
match = re.fullmatch(r"\d+_(.*)", some_string)
812812
assert match is not None
813813
name_group = match.group(1) # The user knows that this will never be None
814-
name_group.uper() # This typo will be flagged by the type checker
814+
name_group.upper() # This typo will be flagged by the type checker
815815

816816
In this case, the user of ``match.group()`` must be prepared to handle a ``str``,
817817
but type checkers are happy with ``if name_group is None`` checks, because we're
818-
saying it can also be something else than an ``str``.
818+
saying it can also be something other than a ``str``.
819819

820820
This is sometimes called "the Any trick".
821821

0 commit comments

Comments
 (0)