Skip to content

Commit 89c5896

Browse files
committed
We're not using docutils, replace :code: with inline literals
1 parent 76cbfeb commit 89c5896

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

pep-0613.rst

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ diagnosis of malformed type aliases downstream.
3838

3939
The following examples each include an illustration of some of the suboptimal
4040
or confusing behaviors resulting from existing implicit alias declarations.
41-
We also introduce explicit aliases of the format :code:`TypeName: TypeAlias = Expression`
41+
We also introduce explicit aliases of the format ``TypeName: TypeAlias = Expression``
4242
here for the sake of comparison, but the syntax is discussed in further detail
4343
in later sections.
4444

@@ -50,10 +50,10 @@ Forward References:
5050
MyType = "ClassName"
5151
def foo() -> MyType: ...
5252

53-
This code snippet should not error so long as :code:`ClassName` is defined
53+
This code snippet should not error so long as ``ClassName`` is defined
5454
later on. However, a type checker is forced to assume that MyType is a value
5555
assignment rather than a type alias, and therefore may throw spurious errors
56-
that (1) :code:`MyType` is an unannotated global string, and (2) :code:`MyType`
56+
that (1) ``MyType`` is an unannotated global string, and (2) ``MyType``
5757
cannot be used as a return annotation because it is not a valid type.
5858

5959
::
@@ -62,7 +62,7 @@ cannot be used as a return annotation because it is not a valid type.
6262
def foo() -> MyType: ...
6363

6464
Explicit aliases remove ambiguity so neither of the above errors will be
65-
thrown. Additionally, if something is wrong with :code:`ClassName`
65+
thrown. Additionally, if something is wrong with ``ClassName``
6666
(i.e., it’s not actually defined later), the type checker can throw an error.
6767

6868

@@ -74,11 +74,11 @@ Error Messaging:
7474
MyType1 = InvalidType
7575
MyType2 = MyGeneric(int) # i.e., intention was MyGeneric[int]
7676

77-
A type checker should warn on this code snippet that :code:`InvalidType` is not
77+
A type checker should warn on this code snippet that ``InvalidType`` is not
7878
a valid type, and therefore cannot be used to annotate an expression or to
7979
construct a type alias. Instead, type checkers are forced to throw spurious
80-
errors that (1) :code:`MyType` is a global expression missing an annotation,
81-
and (2) :code:`MyType` is not a valid type in all usages of :code:`MyType`
80+
errors that (1) ``MyType`` is a global expression missing an annotation,
81+
and (2) ``MyType`` is not a valid type in all usages of ``MyType``
8282
across the codebase.
8383

8484
::
@@ -87,9 +87,9 @@ across the codebase.
8787
MyType2: TypeAlias = MyGeneric(int)
8888

8989
With explicit aliases, the type checker has enough information to error on the
90-
actual definition of the bad type alias, and explain why: that :code:`MyGeneric(int)`
91-
and code:`InvalidType` are not valid types. When the value expression is no longer
92-
evaluated as a global value, unactionable type errors on all usages of :code:`MyType`
90+
actual definition of the bad type alias, and explain why: that ``MyGeneric(int)``
91+
and ``InvalidType`` are not valid types. When the value expression is no longer
92+
evaluated as a global value, unactionable type errors on all usages of ``MyType``
9393
across the codebase can be suppressed.
9494

9595
Scope Restrictions:
@@ -101,8 +101,8 @@ Scope Restrictions:
101101
def foo() -> None:
102102
x = ClassName
103103

104-
The outer :code:`x` is a valid type alias, but type checkers must error if the
105-
inner :code:`x` is ever used as a type because type aliases cannot be defined
104+
The outer ``x`` is a valid type alias, but type checkers must error if the
105+
inner ``x`` is ever used as a type because type aliases cannot be defined
106106
inside a nested scope.
107107
This is confusing because the alias declaration rule is not explicit, and because
108108
a type error will not be thrown on the location of the inner type alias declaration
@@ -158,7 +158,7 @@ Explicit syntax:
158158

159159
Note: The examples above illustrate implicit and explicit alias declarations in
160160
isolation. For the sake of backwards compatibility, type checkers should support
161-
both simultaneously, meaning an untyped global expression :code:`x = int` will
161+
both simultaneously, meaning an untyped global expression ``x = int`` will
162162
still be considered a valid type alias.
163163

164164

@@ -192,11 +192,11 @@ This looks a lot like an uninitialized variable.
192192
MyType = TypeAlias[int]
193193

194194
Along with the option above, this format potentially adds confusion around
195-
what the runtime value of :code:`MyType` is.
195+
what the runtime value of ``MyType`` is.
196196

197197

198-
In comparison, the chosen syntax option :code:`MyType: TypeAlias = int` is
199-
appealing because it still sticks with the :code:`MyType = int` assignment
198+
In comparison, the chosen syntax option ``MyType: TypeAlias = int`` is
199+
appealing because it still sticks with the ``MyType = int`` assignment
200200
syntax, and adds some information for the type checker purely as an annotation.
201201

202202

0 commit comments

Comments
 (0)