From f60074f3d21508bfadcfdd05bddfc07097a0c503 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Thu, 6 Aug 2020 00:05:45 -0700 Subject: [PATCH] Fixed symbol redefinition in cgi.pyi stub (#4394) * PEP 484 says that type checkers should assume that all types used in a stub should use forward declarations even though they are not quoted. This stub is using the symbol "type" within the context of a class scope. The "type" symbol is declared within this scope, so pyright assumes that the forward declaration should be used. The solution is to define a symbol with a different name in the outer scope to avoid the name conflict. * Fixed import sort order. Co-authored-by: Eric Traut --- stdlib/2and3/cgi.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stdlib/2and3/cgi.pyi b/stdlib/2and3/cgi.pyi index 31f03cc62..eeb9b28d8 100644 --- a/stdlib/2and3/cgi.pyi +++ b/stdlib/2and3/cgi.pyi @@ -1,5 +1,6 @@ import sys from _typeshed import SupportsGetItem, SupportsItemAccess +from builtins import type as _type from typing import IO, Any, AnyStr, Dict, Iterable, Iterator, List, Mapping, Optional, Protocol, Tuple, TypeVar, Union _T = TypeVar("_T", bound=FieldStorage) @@ -56,7 +57,7 @@ class MiniFieldStorage: def __repr__(self) -> str: ... class FieldStorage(object): - FieldStorageClass: Optional[type] + FieldStorageClass: Optional[_type] keep_blank_values: int strict_parsing: int qs_on_post: Optional[str]