From 498430e71e9cb10ad6c1c96cadde872a4de86b2e Mon Sep 17 00:00:00 2001 From: Svyatoslav Ilinskiy Date: Fri, 7 Jul 2017 11:55:14 -0700 Subject: [PATCH 1/2] Document `--disallow-any=generics` --- docs/source/command_line.rst | 8 +++++++- docs/source/config_file.rst | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/source/command_line.rst b/docs/source/command_line.rst index 78869fb10bbd..47ea749bb712 100644 --- a/docs/source/command_line.rst +++ b/docs/source/command_line.rst @@ -278,7 +278,8 @@ Here are some more useful flags: - ``--disallow-any`` disallows various types of ``Any`` in a module. The option takes a comma-separated list of the following values: - ``unimported``, ``unannotated``, ``expr``, ``decorated``, ``explicit``. + ``unimported``, ``unannotated``, ``expr``, ``decorated``, ``explicit``, + ``generics``. ``unimported`` disallows usage of types that come from unfollowed imports (such types become aliases for ``Any``). Unfollowed imports occur either @@ -304,6 +305,11 @@ Here are some more useful flags: ``explicit`` disallows explicit ``Any`` in type positions such as type annotations and generic type parameters. + ``generics`` disallows usage of generic types that do not specify explicit + type parameters. Moreover, built-in collections (such as ``list`` and + ``dict``) become disallowed as you should use their aliases from the typing + module (such as ``List`` and ``Dict``). + - ``--disallow-untyped-defs`` reports an error whenever it encounters a function definition without type annotations. diff --git a/docs/source/config_file.rst b/docs/source/config_file.rst index 20fc4241f409..6a32414cc571 100644 --- a/docs/source/config_file.rst +++ b/docs/source/config_file.rst @@ -150,8 +150,8 @@ overridden by the pattern sections matching the module name. - ``disallow_any`` (Comma-separated list, default empty) is an option to disallow various types of ``Any`` in a module. The flag takes a comma-separated list of the following arguments: ``unimported``, - ``unannotated``, ``expr``, ``decorated``, ``explicit``. For explanations - see the discussion for the :ref:`--disallow-any ` option. + ``unannotated``, ``expr``, ``decorated``, ``explicit``, ``generics``. + For explanations see the discussion for the :ref:`--disallow-any ` option. - ``disallow_untyped_calls`` (Boolean, default False) disallows calling functions without type annotations from functions with type From 00322efe7a65098a72b5974da6d79626c2fdf46a Mon Sep 17 00:00:00 2001 From: Svyatoslav Ilinskiy Date: Fri, 7 Jul 2017 12:04:52 -0700 Subject: [PATCH 2/2] Specify type parameters in example --- docs/source/command_line.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/command_line.rst b/docs/source/command_line.rst index 47ea749bb712..727316a34310 100644 --- a/docs/source/command_line.rst +++ b/docs/source/command_line.rst @@ -308,7 +308,7 @@ Here are some more useful flags: ``generics`` disallows usage of generic types that do not specify explicit type parameters. Moreover, built-in collections (such as ``list`` and ``dict``) become disallowed as you should use their aliases from the typing - module (such as ``List`` and ``Dict``). + module (such as ``List[int]`` and ``Dict[str, str]``). - ``--disallow-untyped-defs`` reports an error whenever it encounters a function definition without type annotations.