From e7fc295683464fcca6a94f66fae5178592c3179e Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Sun, 18 Sep 2022 15:16:08 -0700 Subject: [PATCH 1/2] Use the same language in README in the docs intro I previously reworked some of the language in the README and I think it makes sense to re-use the same words in the docs intro. I've merged the two where I felt one was lacking. --- README.md | 21 ++++++++++++------ docs/source/index.rst | 50 +++++++++++++++++++++++++------------------ 2 files changed, 44 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 68e0975a791b..25a12934d637 100644 --- a/README.md +++ b/README.md @@ -58,10 +58,6 @@ Python is a dynamic language, so usually you'll only see errors in your code when you attempt to run it. Mypy is a *static* checker, so it finds bugs in your programs without even running them! -Mypy is designed with gradual typing in mind. This means you can add type -hints to your code base slowly and that you can always fall back to dynamic -typing when static typing is not convenient. - Here is a small example to whet your appetite: ```python @@ -69,13 +65,26 @@ number = input("What is your favourite number?") print("It is", number + 1) # error: Unsupported operand types for + ("str" and "int") ``` -See [the documentation](https://mypy.readthedocs.io/en/stable/index.html) for more examples. +Adding type hints for mypy does not interfere with the way your program would +otherwise run. Think of type hints as similar to comments! You can always use +the Python interpreter to run your code, even if mypy reports type errors. + +Mypy is designed with gradual typing in mind. This means you can add type +hints to your code base slowly and that you can always fall back to dynamic +typing when static typing is not convenient. + +Mypy has a powerful and easy-to-use type system, supporting features such as +type inference, generics, callable types, tuple types, union types, +structural subtyping and more. Using mypy will make your programs easier to +understand, debug, and maintain. + +See [the documentation](https://mypy.readthedocs.io/en/stable/index.html) for +more examples and information. In particular, see: - [type hints cheat sheet](https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html) - [getting started](https://mypy.readthedocs.io/en/stable/getting_started.html) - Quick start ----------- diff --git a/docs/source/index.rst b/docs/source/index.rst index 1cd16ff60af9..ebcc24f2d1dc 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -6,28 +6,36 @@ Welcome to mypy documentation! ============================== -Mypy is a static type checker for Python 3. If you sprinkle -your code with type annotations, mypy can type check your code and find common -bugs. As mypy is a static analyzer, or a lint-like tool, the type -annotations are just hints for mypy and don't interfere when running your program. -You run your program with a standard Python interpreter, and the annotations -are treated effectively as comments. - -Using the Python 3 annotation syntax (using :pep:`484` and :pep:`526` notation), -you will be able to -efficiently annotate your code and use mypy to check the code for common errors. -Mypy has a powerful and easy-to-use type system with modern features such as -type inference, generics, callable types, tuple types, union types, and -structural subtyping. - -As a developer, you decide how to use mypy in your workflow. You can always -escape to dynamic typing as mypy's approach to static typing doesn't restrict -what you can do in your programs. Using mypy will make your programs easier to -understand, debug, and maintain. +Mypy is a static type checker for Python. + +Type checkers help ensure that you're using variables and functions in your code +correctly. With mypy, add type hints (:pep:`484`) +to your Python programs, and mypy will warn you when you use those types +incorrectly. + +Python is a dynamic language, so usually you'll only see errors in your code +when you attempt to run it. Mypy is a *static* checker, so it finds bugs +in your programs without even running them! + +Here is a small example to whet your appetite: + +.. code-block:: python -This documentation provides a short introduction to mypy. It will help you -get started writing statically typed code. Knowledge of Python and a -statically typed object-oriented language, such as Java, are assumed. + number = input("What is your favourite number?") + print("It is", number + 1) # error: Unsupported operand types for + ("str" and "int") + +Adding type hints for mypy does not interfere with the way your program would +otherwise run. Think of type hints as similar to comments! You can always use +the Python interpreter to run your code, even if mypy reports type errors. + +Mypy is designed with gradual typing in mind. This means you can add type +hints to your code base slowly and that you can always fall back to dynamic +typing when static typing is not convenient. + +Mypy has a powerful and easy-to-use type system, supporting features such as +type inference, generics, callable types, tuple types, union types, +structural subtyping and more. Using mypy will make your programs easier to +understand, debug, and maintain. .. note:: From 7e5b93b717074b642126d869339ea75f7194ba24 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Sun, 18 Sep 2022 15:28:34 -0700 Subject: [PATCH 2/2] remove a word --- README.md | 2 +- docs/source/index.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 25a12934d637..95cacb05d682 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ print("It is", number + 1) # error: Unsupported operand types for + ("str" and Adding type hints for mypy does not interfere with the way your program would otherwise run. Think of type hints as similar to comments! You can always use -the Python interpreter to run your code, even if mypy reports type errors. +the Python interpreter to run your code, even if mypy reports errors. Mypy is designed with gradual typing in mind. This means you can add type hints to your code base slowly and that you can always fall back to dynamic diff --git a/docs/source/index.rst b/docs/source/index.rst index ebcc24f2d1dc..1f77e951843d 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -26,7 +26,7 @@ Here is a small example to whet your appetite: Adding type hints for mypy does not interfere with the way your program would otherwise run. Think of type hints as similar to comments! You can always use -the Python interpreter to run your code, even if mypy reports type errors. +the Python interpreter to run your code, even if mypy reports errors. Mypy is designed with gradual typing in mind. This means you can add type hints to your code base slowly and that you can always fall back to dynamic