Skip to content

Commit 6a50192

Browse files
authored
Use the same language in the docs intro and README (#13677)
1 parent e40d214 commit 6a50192

File tree

2 files changed

+44
-27
lines changed

2 files changed

+44
-27
lines changed

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,24 +58,33 @@ Python is a dynamic language, so usually you'll only see errors in your code
5858
when you attempt to run it. Mypy is a *static* checker, so it finds bugs
5959
in your programs without even running them!
6060

61-
Mypy is designed with gradual typing in mind. This means you can add type
62-
hints to your code base slowly and that you can always fall back to dynamic
63-
typing when static typing is not convenient.
64-
6561
Here is a small example to whet your appetite:
6662

6763
```python
6864
number = input("What is your favourite number?")
6965
print("It is", number + 1) # error: Unsupported operand types for + ("str" and "int")
7066
```
7167

72-
See [the documentation](https://mypy.readthedocs.io/en/stable/index.html) for more examples.
68+
Adding type hints for mypy does not interfere with the way your program would
69+
otherwise run. Think of type hints as similar to comments! You can always use
70+
the Python interpreter to run your code, even if mypy reports errors.
71+
72+
Mypy is designed with gradual typing in mind. This means you can add type
73+
hints to your code base slowly and that you can always fall back to dynamic
74+
typing when static typing is not convenient.
75+
76+
Mypy has a powerful and easy-to-use type system, supporting features such as
77+
type inference, generics, callable types, tuple types, union types,
78+
structural subtyping and more. Using mypy will make your programs easier to
79+
understand, debug, and maintain.
80+
81+
See [the documentation](https://mypy.readthedocs.io/en/stable/index.html) for
82+
more examples and information.
7383

7484
In particular, see:
7585
- [type hints cheat sheet](https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html)
7686
- [getting started](https://mypy.readthedocs.io/en/stable/getting_started.html)
7787

78-
7988
Quick start
8089
-----------
8190

docs/source/index.rst

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,36 @@
66
Welcome to mypy documentation!
77
==============================
88

9-
Mypy is a static type checker for Python 3. If you sprinkle
10-
your code with type annotations, mypy can type check your code and find common
11-
bugs. As mypy is a static analyzer, or a lint-like tool, the type
12-
annotations are just hints for mypy and don't interfere when running your program.
13-
You run your program with a standard Python interpreter, and the annotations
14-
are treated effectively as comments.
15-
16-
Using the Python 3 annotation syntax (using :pep:`484` and :pep:`526` notation),
17-
you will be able to
18-
efficiently annotate your code and use mypy to check the code for common errors.
19-
Mypy has a powerful and easy-to-use type system with modern features such as
20-
type inference, generics, callable types, tuple types, union types, and
21-
structural subtyping.
22-
23-
As a developer, you decide how to use mypy in your workflow. You can always
24-
escape to dynamic typing as mypy's approach to static typing doesn't restrict
25-
what you can do in your programs. Using mypy will make your programs easier to
26-
understand, debug, and maintain.
9+
Mypy is a static type checker for Python.
10+
11+
Type checkers help ensure that you're using variables and functions in your code
12+
correctly. With mypy, add type hints (:pep:`484`)
13+
to your Python programs, and mypy will warn you when you use those types
14+
incorrectly.
15+
16+
Python is a dynamic language, so usually you'll only see errors in your code
17+
when you attempt to run it. Mypy is a *static* checker, so it finds bugs
18+
in your programs without even running them!
19+
20+
Here is a small example to whet your appetite:
21+
22+
.. code-block:: python
2723
28-
This documentation provides a short introduction to mypy. It will help you
29-
get started writing statically typed code. Knowledge of Python and a
30-
statically typed object-oriented language, such as Java, are assumed.
24+
number = input("What is your favourite number?")
25+
print("It is", number + 1) # error: Unsupported operand types for + ("str" and "int")
26+
27+
Adding type hints for mypy does not interfere with the way your program would
28+
otherwise run. Think of type hints as similar to comments! You can always use
29+
the Python interpreter to run your code, even if mypy reports errors.
30+
31+
Mypy is designed with gradual typing in mind. This means you can add type
32+
hints to your code base slowly and that you can always fall back to dynamic
33+
typing when static typing is not convenient.
34+
35+
Mypy has a powerful and easy-to-use type system, supporting features such as
36+
type inference, generics, callable types, tuple types, union types,
37+
structural subtyping and more. Using mypy will make your programs easier to
38+
understand, debug, and maintain.
3139

3240
.. note::
3341

0 commit comments

Comments
 (0)