Skip to content

Commit d71269e

Browse files
authored
docs: rename mypy guide to typing (#836)
Rename the guide page from `mypy` to `typing` and generalize its text from "mypy" to "type checker". A meta-refresh stub keeps the old `/guides/mypy/` URL working on Read the Docs. Assisted-by: ClaudeCode:claude-opus-4.8
1 parent 812ba3d commit d71269e

7 files changed

Lines changed: 32 additions & 25 deletions

File tree

.readthedocs.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ build:
1313
- npm install -g mystmd
1414
# Build the site
1515
- cd docs && myst build --html
16+
# Redirect the old /guides/mypy/ URL to /guides/typing/
17+
- mkdir -p docs/_build/html/guides/mypy
18+
- cp redirect-stubs/guides/mypy/index.html docs/_build/html/guides/mypy/index.html
1619
# Copy the output to Read the Docs expected location
1720
- mkdir -p $READTHEDOCS_OUTPUT/html/
1821
- cp -r docs/_build/html/. "$READTHEDOCS_OUTPUT/html"

docs/guides/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ WebAssembly! All checks point to a linked badge in the guide.
3737

3838
[tutorials]: /tutorials/index.md
3939
[style]: /guides/style.md
40-
[mypy]: /guides/mypy.md
40+
[mypy]: /guides/typing.md
4141
[docs]: /guides/docs.md
4242
[simple packaging]: /guides/packaging_simple.md
4343
[compiled packaging]: /guides/packaging_compiled.md

docs/guides/style.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ for a specific rule); the standard `# type: ignore` is honored as well.
786786
:::
787787
::::
788788

789-
[mypy page]: /guides/mypy.md
789+
[mypy page]: /guides/typing.md
790790

791791
## Setuptools specific checks
792792

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,16 @@ expected really gives you a much better idea of what is going on and what you
2222
can do and can't do.
2323

2424
But the key goal is: static type checking! There are a collection of static type
25-
checkers, the most "official" and famous of which is MyPy. You can think of this
26-
as the "compiler" for compiled languages like C++; it checks to make sure you
27-
are not lying about the types. For example, passing in anything that is not an
28-
int to `f` will fail a mypy check, _before you run or deploy any code_.
25+
checkers to choose from. You can think of a type checker as the "compiler" for
26+
compiled languages like C++; it checks to make sure you are not lying about the
27+
types. For example, passing in anything that is not an int to `f` will fail the
28+
type checker, _before you run or deploy any code_.
2929

30-
Your tests cannot test every possible branch, every line of code. MyPy can
31-
(though it doesn't by default, due to gradual typing). You may have code that
32-
runs rarely, that requires remote resources, that is slow, etc. All those can be
33-
checked by MyPy. It also keeps you (too?) truthful in your types.
30+
Your tests cannot test every possible branch, every line of code. A type
31+
checker can (though it doesn't by default, due to gradual typing). You may have
32+
code that runs rarely, that requires remote resources, that is slow, etc. All
33+
those can be checked by the type checker. It also keeps you (too?) truthful in
34+
your types.
3435

3536
### Adding types
3637

@@ -45,20 +46,22 @@ There are three ways to add types.
4546
libraries you don't control this way.
4647

4748
If you have a library you don't control, you can add "type stubs" for it, then
48-
give MyPy your stubs directory. MyPy will pull the types from your stubs. If you
49-
are writing code for a Raspberry Pi, for example, you could add the stubs for
49+
give the type checker your stubs directory. It will pull the types from your
50+
stubs. If you are writing code for a Raspberry Pi, for example, you could add
51+
the stubs for
5052
the Pi libraries, and then validate your code, without ever even installing the
5153
Pi-only libraries!
5254

5355
You do not have to add types for every object - most of the time, you just need
54-
it for parameters and returns from functions. When running MyPy, you can use
55-
`reveal_type(...)` to show the inferred type of any object, which is like a
56-
print statement but at type-checking time, or `reveal_locals()` to see all local
57-
types.
56+
it for parameters and returns from functions. When running the type checker, you
57+
can use `reveal_type(...)` to show the inferred type of any object, which is
58+
like a print statement but at type-checking time, or `reveal_locals()` to see
59+
all local types.
5860

5961
### Configuration
6062

61-
By default, MyPy does as little as possible, so that you can add it iteratively
63+
By default, the type checker does as little as possible, so that you can add it
64+
iteratively
6265
to a code base. By default:
6366

6467
- All untyped variables and return values will be `Any`.
@@ -74,8 +77,8 @@ suggestions.
7477

7578
For a library to support typing, it has to a) add types using any of the three
7679
methods, and b) add a `py.typed` empty file to indicate that it's okay to look
77-
for types inside it. MyPy also looks in `typeshed`, which is a library full of
78-
type hints for (mostly) the standard library.
80+
for types inside it. The type checker also looks in `typeshed`, which is a
81+
library full of type hints for (mostly) the standard library.
7982

8083
Third party libraries that are typed sometimes forget this last step, by the
8184
way!
@@ -114,8 +117,8 @@ This will print `A` because you removed B via the type narrowing using the
114117

115118
### Protocols
116119

117-
One of the best features of MyPy is support for structural subtyping via
118-
Protocols - formalized duck-typing, basically. This allows cross library
120+
One of the best features of type checkers is support for structural subtyping
121+
via Protocols - formalized duck-typing, basically. This allows cross library
119122
interoperability, unlike traditional inheritance. Here’s how it works:
120123

121124
```python
@@ -173,8 +176,8 @@ Static typing has some great features worth checking out:
173176
- Literals
174177
- TypedDict
175178
- Nicer NamedTuple definition (very popular in Python 3 code)
176-
- MyPy validates with the Python version you ask for, regardless of what version
177-
you are actually running.
179+
- The type checker validates with the Python version you ask for, regardless of
180+
what version you are actually running.
178181

179182
## Complete example
180183

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ by NSF grant [OAC-2209877][].
8080
[style checking]: /guides/style.md
8181
[testing]: /guides/pytest.md
8282
[documentation]: /guides/docs.md
83-
[static typing]: /guides/mypy.md
83+
[static typing]: /guides/typing.md
8484
[ci]: /guides/gha_pure.md
8585
[right in the guide]: /guides/repo_review.md
8686

docs/myst.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ project:
2626
- file: guides/packaging_compiled.md
2727
- file: guides/packaging_classic.md
2828
- file: guides/style.md
29-
- file: guides/mypy.md
29+
- file: guides/typing.md
3030
- file: guides/gha_basic.md
3131
- file: guides/gha_pure.md
3232
- file: guides/gha_wheels.md
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!doctype html><meta http-equiv="refresh" content="0; url=/guides/typing/" />

0 commit comments

Comments
 (0)