Skip to content

Commit 9e884d2

Browse files
committed
PEP 622: Fix various nits reported by the SC
1 parent 3b480d1 commit 9e884d2

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

pep-0622.rst

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ proposed syntax and semantics.
5555
Overview
5656
========
5757

58-
Since patterns are a new syntactical category with their own rules
58+
Since patterns are a new syntactic category with their own rules
5959
and special cases, and since they mix input (given values) and output
6060
(captured variables) in novel ways, they require a bit of getting used
6161
to. It is the experience of the authors that this happens quickly when
@@ -285,7 +285,7 @@ Syntax and Semantics
285285
Patterns
286286
--------
287287

288-
The **pattern** is a new syntactical construct, that could be considered a loose
288+
The **pattern** is a new syntactic construct, that could be considered a loose
289289
generalization of assignment targets. The key properties of a pattern are what
290290
types and shapes of subjects it accepts, what variables it captures and how
291291
it extracts them from the subject. For example the pattern ``[a, b]`` matches
@@ -371,7 +371,6 @@ this section are there for helping the reader, not as a full specification.
371371

372372
We propose that the match operation should be a statement, not an expression.
373373
Although in
374-
375374
many languages it is an expression, being a statement better suits the general
376375
logic of Python syntax. See `rejected ideas`_ for more discussion.
377376
The allowed patterns are described in detail below in the `patterns`_
@@ -654,7 +653,7 @@ Simplified syntax::
654653

655654
Mapping pattern is a generalization of iterable unpacking to mappings.
656655
Its syntax is similar to dictionary display but each key and value are
657-
patterns ``"{" (pattern ":" pattern)+ "}"``. A ``**name`` pattern is also
656+
patterns ``"{" (pattern ":" pattern)+ "}"``. A ``**rest`` pattern is also
658657
allowed, to extract the remaining items. Only literal and constant value
659658
patterns are allowed in key positions::
660659

@@ -700,7 +699,7 @@ Simplified syntax::
700699
A class pattern provides support for destructuring arbitrary objects.
701700
There are two possible ways of matching on object attributes: by position
702701
like ``Point(1, 2)``, and by name like ``Point(x=1, y=2)``. These
703-
two can be combined, but positional match cannot follow a match by name.
702+
two can be combined, but a positional match cannot follow a match by name.
704703
Each item in a class pattern can be an arbitrary pattern. A simple
705704
example::
706705

@@ -735,7 +734,7 @@ Combining multiple patterns (OR patterns)
735734

736735
Multiple alternative patterns can be combined into one using ``|``. This means
737736
the whole pattern matches if at least one alternative matches.
738-
Alternatives are tried from left to right and have short-circuit property,
737+
Alternatives are tried from left to right and have a short-circuit property,
739738
subsequent patterns are not tried if one matched. Examples::
740739

741740
match something:
@@ -858,7 +857,7 @@ The procedure is as following:
858857
sub-patterns succeed, the overall class pattern match succeeds.
859858

860859
* If there are match-by-position items and the class has a
861-
``__match_args__``, the item at position ``i``
860+
``__match_args__`` attribute, the item at position ``i``
862861
is matched against the value looked up by attribute
863862
``__match_args__[i]``. For example, a pattern ``Point2D(5, 8)``,
864863
where ``Point2D.__match_args__ == ["x", "y"]``, is translated
@@ -1146,7 +1145,7 @@ Note about constants
11461145
The fact that a capture pattern is always an assignment target may create unwanted
11471146
consequences when a user by mistake tries to "match" a value against
11481147
a constant instead of using the constant value pattern. As a result, at
1149-
runtime such match will always succeed and moreover override the value of
1148+
runtime such a match will always succeed and moreover override the value of
11501149
the constant. It is important therefore that static type checkers warn about
11511150
such situations. For example::
11521151

@@ -1224,7 +1223,7 @@ desire to break or deprecate.
12241223
The difference between hard and soft keywords is that hard keywords
12251224
are *always* reserved words, even in positions where they make no
12261225
sense (e.g. ``x = class + 1``), while soft keywords only get a special
1227-
meaning in context. Since our parser backtracks, that means that on
1226+
meaning in context. Since PEP 617 the parser backtracks, that means that on
12281227
different attempts to parse a code fragment it could interpret a soft
12291228
keyword differently.
12301229

@@ -1340,12 +1339,12 @@ in a cleaner and more maintainable architecture. These use cases tend to
13401339
be characterized by a number of features:
13411340

13421341
* Algorithms which cut across traditional lines of data encapsulation. If an
1343-
algorithm is processing heterogenous elements of different types (such as
1342+
algorithm is processing heterogeneous elements of different types (such as
13441343
evaluating or transforming an abstract syntax tree, or doing algebraic
13451344
manipulation of mathematical symbols), forcing the user to implement
13461345
the algorithm as individual methods on each element type results in
13471346
logic that is smeared across the entire codebase instead of being neatly
1348-
localized in once place.
1347+
localized in one place.
13491348
* Program architectures where the set of possible data types is relatively
13501349
stable, but there is an ever-expanding set of operations to be performed
13511350
on those data types. Doing this in a strict OOP fashion requires constantly
@@ -2112,7 +2111,7 @@ Pattern Utility Library
21122111
-----------------------
21132112

21142113
Both of the previous ideas would be accompanied by a new Python standard
2115-
library module which would contain a rich set of exotic and useful matchers.
2114+
library module which would contain a rich set of useful matchers.
21162115
However, it it not really possible to implement such a library without
21172116
adopting one of the extended pattern proposals given in the previous sections,
21182117
so this idea is also deferred.

0 commit comments

Comments
 (0)