Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PEP 585 syntax everywhere #6681

Closed
wants to merge 5 commits into from

Conversation

AlexWaygood
Copy link
Member

This will probably be easiest to review commit by commit.

The script I used to apply these changes is as follows:

import ast
import re
from collections import defaultdict
from itertools import chain
from pathlib import Path
from typing import NamedTuple


class DeleteableImport(NamedTuple):
    old: str
    replacement: str


BAD_CLASSES = frozenset({"List", "FrozenSet", "Set", "Deque", "Dict", "DefaultDict", "Tuple", "Type"})
CAPITAL_T_TYPE_ALLOWLIST = frozenset({Path("stdlib/dataclasses.pyi"), Path("stdlib/asyncio/trsock.pyi")})


def fix_bad_syntax(path: Path) -> None:
    if "@python2" in path.parts or Path("stubs/protobuf/google/protobuf") in path.parents:
        return

    with open(path) as f:
        stub = f.read()

    lines = stub.splitlines()
    tree = ast.parse(stub)
    imports_to_delete = {}
    classes_from_typing = set()

    class BadImportFinder(ast.NodeVisitor):
        def visit_ImportFrom(self, node: ast.ImportFrom, bad_classes=BAD_CLASSES) -> None:
            if node.module == "typing":
                if path in CAPITAL_T_TYPE_ALLOWLIST:
                    bad_classes = BAD_CLASSES - {"Type"}
                if path == Path("stdlib/csv.pyi"):
                    bad_classes -= {"Dict"}

                bad_classes_in_this_import = {cls.name for cls in node.names if cls.asname is None} & bad_classes
                classes_from_typing.update(bad_classes_in_this_import)
                new_import_list = [cls for cls in node.names if cls.name not in classes_from_typing]
                node_line_length = node.end_lineno - node.lineno + 1

                if not bad_classes_in_this_import:
                    return

                if not new_import_list:
                    imports_to_delete[node.lineno - 1] = DeleteableImport(old=ast.unparse(node), replacement="")
                    return

                if node.lineno == node.end_lineno:
                    imports_to_delete[node.lineno - 1] = DeleteableImport(
                        old=ast.unparse(node),
                        replacement=ast.unparse(ast.ImportFrom(module="typing", names=new_import_list, level=0)),
                    )
                    return

                for cls in node.names:
                    if cls.name in bad_classes_in_this_import:
                        imports_to_delete[cls.lineno - 1] = DeleteableImport(old=f"{cls.name},", replacement="")

    BadImportFinder().visit(tree)

    if not classes_from_typing:
        return

    for lineno, (old_syntax, new_syntax) in imports_to_delete.items():
        lines[lineno] = lines[lineno].replace(old_syntax, new_syntax)

    new_tree = ast.parse("\n".join(lines))
    lines_with_bad_syntax = defaultdict(list)

    class OldSyntaxFinder(ast.NodeVisitor):
        def visit_Subscript(self, node: ast.Subscript) -> None:
            if isinstance(node.value, ast.Name) and node.value.id in classes_from_typing:
                lines_with_bad_syntax[node.lineno - 1].append(node.value.id)
            self.generic_visit(node)

    OldSyntaxFinder().visit(new_tree)

    for i, cls_list in lines_with_bad_syntax.items():
        for cls in cls_list:
            lines[i] = re.sub(fr"(\W){cls}\[", fr"\1{cls.lower()}[", lines[i])

    with open(path, "w") as f:
        f.write("\n".join(lines) + "\n")


def main() -> None:
    for path in chain(Path("stdlib").rglob("*.pyi"), Path("stubs").rglob("*.pyi")):
        fix_bad_syntax(path)


if __name__ == "__main__":
    main()

Note: this doesn't touch any classes from collections.abc. I probably could have done them in this PR as well, but I haven't.

@AlexWaygood AlexWaygood marked this pull request as draft December 24, 2021 15:24
@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

black (https://github.com/psf/black)
+ src/blib2to3/pgen2/grammar.py:149:9: error: Returning Any from function declared to return "_P"
+ src/black/files.py:44:21: error: <nothing> has no attribute "resolve"
+ src/black_primer/cli.py:27:14: error: <nothing> has no attribute "strftime"
+ src/black/__init__.py:203:23: error: Need type annotation for "v"
+ src/black/__init__.py:809:12: error: Need type annotation for "then"
+ src/black/__init__.py:825:15: error: Need type annotation for "now"
+ src/black/__init__.py:865:12: error: Need type annotation for "then"
+ src/black/__init__.py:890:19: error: Need type annotation for "now"
+ src/black/__init__.py:1263:12: error: Need type annotation for "version"
+ src/blackd/__init__.py:124:16: error: Need type annotation for "then"
+ src/blackd/__init__.py:134:19: error: Need type annotation for "now"

isort (https://github.com/pycqa/isort)
+ isort/output.py:633: error: Need type annotation for "instance"
+ isort/output.py:635: error: Returning Any from function declared to return "_LineWithComments"
+ isort/main.py:546: error: "_T" has no attribute "value"

sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/util/logging.py:498: error: Unused "type: ignore" comment
+ sphinx/util/__init__.py: note: In function "epoch_to_rfc1123":
+ sphinx/util/__init__.py:556:10: error: Need type annotation for "dt"
+ sphinx/builders/gettext.py:171:11: error: Unsupported left operand type for - (<nothing>)
+ sphinx/builders/gettext.py: note: In member "finish" of class "MessageCatalogBuilder":
+ sphinx/builders/gettext.py:268:22: error: <nothing> has no attribute "strftime"
+ sphinx/transforms/post_transforms/images.py: note: In member "match" of class "ImageConverter":
+ sphinx/transforms/post_transforms/images.py:205:13: error: "type" has no attribute "available"
+ sphinx/testing/fixtures.py:110: error: Unused "type: ignore" comment
+ sphinx/builders/html/__init__.py: note: In member "__new__" of class "Stylesheet":
+ sphinx/builders/html/__init__.py:92:16: error: Need type annotation for "self"
+ sphinx/builders/html/__init__.py: note: In member "__new__" of class "JavaScript":
+ sphinx/builders/html/__init__.py:117:16: error: Need type annotation for "self"

schemathesis (https://github.com/schemathesis/schemathesis)
+ src/schemathesis/models.py: note: In class "Interaction":
+ src/schemathesis/models.py:827: error: <nothing> has no attribute "isoformat"
+ src/schemathesis/cli/__init__.py: note: In member "format_options" of class "CommandWithCustomHelp":
+ src/schemathesis/cli/__init__.py:159: error: <nothing> has no attribute "value"
+ src/schemathesis/cli/__init__.py: note: At top level:
+ src/schemathesis/cli/__init__.py:192: error: Need type annotation for "item"
+ src/schemathesis/cli/__init__.py:386: error: Need type annotation for "item"
+ src/schemathesis/cli/__init__.py:402: error: Need type annotation for "item"

pandas (https://github.com/pandas-dev/pandas)
+ pandas/_typing.py:108: error: Type application has too few types (2 expected)  [misc]
+ pandas/_libs/tslibs/timestamps.pyi:82: error: Return type "Timestamp" of "fromtimestamp" incompatible with return type "_S" in supertype "datetime"  [override]
+ pandas/_libs/tslibs/timestamps.pyi:82: error: Signature of "fromtimestamp" incompatible with supertype "date"  [override]
+ pandas/_libs/tslibs/timestamps.pyi:82: note:      Superclass:
+ pandas/_libs/tslibs/timestamps.pyi:82: note:          @classmethod
+ pandas/_libs/tslibs/timestamps.pyi:82: note:          def [_S] fromtimestamp(cls, float) -> _S
+ pandas/_libs/tslibs/timestamps.pyi:82: note:      Subclass:
+ pandas/_libs/tslibs/timestamps.pyi:82: note:          @classmethod
+ pandas/_libs/tslibs/timestamps.pyi:82: note:          def fromtimestamp(cls, t: float, tz: Optional[tzinfo] = ...) -> Timestamp
+ pandas/_libs/tslibs/timestamps.pyi:86: error: Return type "Timestamp" of "utcfromtimestamp" incompatible with return type "_S" in supertype "datetime"  [override]
+ pandas/_libs/tslibs/timestamps.pyi:88: error: Signature of "today" incompatible with supertype "date"  [override]
+ pandas/_libs/tslibs/timestamps.pyi:88: note:      Superclass:
+ pandas/_libs/tslibs/timestamps.pyi:88: note:          @classmethod
+ pandas/_libs/tslibs/timestamps.pyi:88: note:          def [_S] today(cls) -> _S
+ pandas/_libs/tslibs/timestamps.pyi:88: note:      Subclass:
+ pandas/_libs/tslibs/timestamps.pyi:88: note:          @classmethod
+ pandas/_libs/tslibs/timestamps.pyi:88: note:          def today(cls, tz: Union[tzinfo, str, None] = ...) -> Timestamp
+ pandas/_libs/tslibs/timestamps.pyi:90: error: Signature of "fromordinal" incompatible with supertype "date"  [override]
+ pandas/_libs/tslibs/timestamps.pyi:90: note:      Superclass:
+ pandas/_libs/tslibs/timestamps.pyi:90: note:          @classmethod
+ pandas/_libs/tslibs/timestamps.pyi:90: note:          def [_S] fromordinal(cls, int) -> _S
+ pandas/_libs/tslibs/timestamps.pyi:90: note:      Subclass:
+ pandas/_libs/tslibs/timestamps.pyi:90: note:          @classmethod
+ pandas/_libs/tslibs/timestamps.pyi:90: note:          def fromordinal(cls, ordinal: int, freq: Union[str, Any, None] = ..., tz: Union[tzinfo, str, None] = ...) -> Timestamp
+ pandas/_libs/tslibs/timestamps.pyi:97: error: Return type "Timestamp" of "now" incompatible with return type "_S" in supertype "datetime"  [override]
+ pandas/_libs/tslibs/timestamps.pyi:99: error: Return type "Timestamp" of "utcnow" incompatible with return type "_S" in supertype "datetime"  [override]
+ pandas/_libs/tslibs/timestamps.pyi:104: error: Return type "Timestamp" of "fromisoformat" incompatible with return type "_S" in supertype "datetime"  [override]
+ pandas/_libs/tslibs/timestamps.pyi:104: error: Return type "Timestamp" of "fromisoformat" incompatible with return type "_S" in supertype "date"  [override]
+ pandas/core/dtypes/dtypes.py:189: error: Need type annotation for "self"  [var-annotated]
+ pandas/core/dtypes/dtypes.py:1076: error: Need type annotation for "u"  [var-annotated]
+ pandas/core/indexes/base.py:652: error: Need type annotation for "result"  [var-annotated]
+ pandas/core/arrays/string_.py:352: error: Need type annotation for "new_string_array"  [var-annotated]
+ pandas/core/arrays/sparse/array.py:527: error: Need type annotation for "new"  [var-annotated]
+ pandas/core/indexes/range.py:169: error: Need type annotation for "result"  [var-annotated]
+ pandas/core/indexes/multi.py:323: error: Need type annotation for "result"  [var-annotated]
+ pandas/core/indexes/multi.py:332: error: Unused "type: ignore" comment
+ pandas/io/parsers/python_parser.py:222: error: "type" has no attribute "delimiter"  [attr-defined]
+ pandas/core/generic.py:296: error: Need type annotation for "obj"  [var-annotated]
+ pandas/compat/pickle_compat.py:216: error: Need type annotation for "obj"  [var-annotated]
+ pandas/compat/pickle_compat.py:241: error: Need type annotation for "obj"  [var-annotated]
+ pandas/tseries/holiday.py:379: error: Need type annotation for "calendar_class"  [var-annotated]
+ pandas/tests/groupby/test_apply.py:800: error: <nothing> has no attribute "date"  [attr-defined]
+ pandas/tests/groupby/test_apply.py:800: error: <nothing> has no attribute "time"  [attr-defined]
+ pandas/plotting/_matplotlib/converter.py:452: error: Need type annotation for "dt"  [var-annotated]

bokeh (https://github.com/bokeh/bokeh)
+ release/action.py: note: In member "__str__" of class "ActionReturn":
+ release/action.py:33:16: error: "type" has no attribute "ui"  [attr-defined]
+ bokeh/palettes.py:372: error: Type application has too few types (2 expected)  [misc]
+ release/stages.py:79: error: Type application has too few types (2 expected)  [misc]

SinbadCogs (https://github.com/mikeshardmind/SinbadCogs)
+ rolemanagement/events.py:41: error: Need type annotation for "now"
+ scheduler/converters.py:96: error: Incompatible types in assignment (expression has type "timedelta", variable has type "datetime")
+ scheduler/converters.py:144: error: Incompatible types in assignment (expression has type "timedelta", variable has type "datetime")
+ modnotes/modnotes.py:148: error: <nothing> has no attribute "timestamp"
+ scheduler/tasks.py:75: error: Need type annotation for "initial"
+ scheduler/tasks.py:100: error: Need type annotation for "now"
+ scheduler/tasks.py:104: error: Returning Any from function declared to return "float"
+ scheduler/tasks.py:106: error: Returning Any from function declared to return "float"
+ scheduler/tasks.py:110: error: Need type annotation for "now"
+ scheduler/scheduler.py:759: error: Need type annotation for "now"
+ scheduler/scheduler.py:822: error: Need type annotation for "now"

manticore (https://github.com/trailofbits/manticore)
+ manticore/utils/helpers.py:185: error: Need type annotation for "now"
+ manticore/core/plugin.py:432: error: Incompatible types in assignment (expression has type "_S", variable has type "datetime")
+ manticore/core/plugin.py:436: error: Incompatible types in assignment (expression has type "_S", variable has type "datetime")
+ manticore/core/worker.py:361: error: Need type annotation for "now"
+ tests/native/test_linux.py:97: error: Need type annotation for "ex"
+ tests/native/test_linux.py:335: error: Need type annotation for "cm"

mkosi (https://github.com/systemd/mkosi)
+ mkosi/backend.py:138:17: error: Need type annotation for "entry"  [var-annotated]
+ mkosi/backend.py:141:9: error: Returning Any from function declared to return "Distribution"  [no-any-return]
+ mkosi/manifest.py:74:33: error: Incompatible types in assignment (expression has type "_S", variable has type "datetime")  [assignment]
+ mkosi/manifest.py:112:27: error: Need type annotation for "installtime"  [var-annotated]
+ mkosi/manifest.py:154:27: error: Need type annotation for "installtime"  [var-annotated]
+ mkosi/__init__.py:4029:34: error: Unsupported left operand type for + (<nothing>)  [operator]
+ mkosi/__init__.py:5418:14: error: Argument "type" to "add_argument" of "_ActionsContainer" has incompatible type "Callable[[str], Optional[SourceFileTransfer]]"; expected "Union[Callable[[str], Optional[_T]], FileType]"  [arg-type]
+ mkosi/__init__.py:5427:14: error: Argument "type" to "add_argument" of "_ActionsContainer" has incompatible type "Callable[[str], Optional[SourceFileTransfer]]"; expected "Union[Callable[[str], Optional[_T]], FileType]"  [arg-type]
+ mkosi/__init__.py:5804:13: error: Incompatible types in assignment (expression has type "Union[_T, Distribution, None]", variable has type "Optional[Distribution]")  [assignment]

core (https://github.com/home-assistant/core)
+ homeassistant/util/dt.py:104: error: Returning Any from function declared to return "datetime"  [no-any-return]
+ homeassistant/util/dt.py:104: error: <nothing> has no attribute "replace"  [attr-defined]
+ homeassistant/setup.py:30: error: Need type annotation for "platform"  [var-annotated]
+ homeassistant/config_entries.py:94: error: Need type annotation for "obj"  [var-annotated]
- homeassistant/config_entries.py:95: error: "object" has no attribute "_value_"  [attr-defined]
- homeassistant/config_entries.py:96: error: "object" has no attribute "_recoverable"  [attr-defined]
+ homeassistant/helpers/entity.py:875: error: "object" has no attribute "unique_id"  [attr-defined]
+ homeassistant/helpers/entity.py:879: error: "object" has no attribute "platform"  [attr-defined]
+ homeassistant/helpers/entity.py:880: error: "object" has no attribute "platform"  [attr-defined]
+ homeassistant/helpers/entity.py:883: error: "object" has no attribute "platform"  [attr-defined]
+ homeassistant/helpers/entity.py:886: error: Returning Any from function declared to return "bool"  [no-any-return]
+ homeassistant/helpers/entity.py:886: error: "object" has no attribute "unique_id"  [attr-defined]
+ homeassistant/components/sensor/__init__.py:170: error: Need type annotation for "cls"  [var-annotated]
+ homeassistant/components/sensor/__init__.py:194: error: Need type annotation for "cls"  [var-annotated]
+ homeassistant/components/switch/__init__.py:58: error: Need type annotation for "cls"  [var-annotated]
+ homeassistant/components/starline/account.py:44: error: <nothing> has no attribute "timestamp"  [attr-defined]
+ homeassistant/components/starline/account.py:144: error: <nothing> has no attribute "isoformat"  [attr-defined]
+ homeassistant/components/nina/__init__.py:106: error: <nothing> has no attribute "astimezone"  [attr-defined]
+ homeassistant/components/mysensors/helpers.py:179: error: Need type annotation for "member"  [var-annotated]
+ homeassistant/components/mysensors/helpers.py:179: error: Item "str" of "Optional[str]" has no attribute "name"  [union-attr]
+ homeassistant/components/mysensors/helpers.py:179: error: Item "None" of "Optional[str]" has no attribute "name"  [union-attr]
+ homeassistant/components/mysensors/helpers.py:179: error: Item "str" of "Optional[str]" has no attribute "value"  [union-attr]
+ homeassistant/components/mysensors/helpers.py:179: error: Item "None" of "Optional[str]" has no attribute "value"  [union-attr]
+ homeassistant/components/mysensors/helpers.py:186: error: Need type annotation for "member"  [var-annotated]
+ homeassistant/components/mysensors/helpers.py:200: error: Need type annotation for "member"  [var-annotated]
+ homeassistant/components/mysensors/helpers.py:223: error: <nothing> has no attribute "value"  [attr-defined]
+ homeassistant/components/cover/__init__.py:69: error: Need type annotation for "cls"  [var-annotated]
+ homeassistant/components/binary_sensor/__init__.py:120: error: Need type annotation for "cls"  [var-annotated]
+ homeassistant/components/vicare/__init__.py:65: error: Need type annotation for "e"  [var-annotated]
+ homeassistant/components/vallox/sensor.py:106: error: <nothing> has no attribute "replace"  [attr-defined]
+ homeassistant/components/vallox/sensor.py:108: error: Returning Any from function declared to return "Union[Union[None, str, int, float], datetime]"  [no-any-return]
+ homeassistant/components/todoist/calendar.py:235: error: <nothing> has no attribute "replace"  [attr-defined]
+ homeassistant/components/media_player/__init__.py:158: error: Need type annotation for "cls"  [var-annotated]
+ homeassistant/components/stream/worker.py:123: error: Need type annotation for "_start_time"  [var-annotated]
+ homeassistant/components/vicare/config_flow.py:51: error: Need type annotation for "e"  [var-annotated]
+ homeassistant/components/androidtv/media_player.py:426: error: <nothing> has no attribute "timestamp"  [attr-defined]
+ homeassistant/components/netatmo/media_source.py:80: error: Need type annotation for "created"  [var-annotated]

mypy (https://github.com/python/mypy)
+ mypy/typestate.py:19: error: Type application has too few types (2 expected)  [misc]
+ mypy/server/astdiff.py:74: error: Type application has too few types (2 expected)  [misc]
+ mypy/literals.py:85: error: Type application has too few types (2 expected)  [misc]
+ mypyc/transform/refcount.py:36: error: Type application has too few types (2 expected)  [misc]
+ mypyc/transform/refcount.py:37: error: Type application has too few types (2 expected)  [misc]
+ mypyc/codegen/emitwrapper.py:80: error: Need type annotation for "k"  [var-annotated]
+ mypy/test/teststubgen.py:1045: error: Need type annotation for "e"  [var-annotated]

tornado (https://github.com/tornadoweb/tornado)
+ tornado/util.py:276: error: Need type annotation for "instance"
+ tornado/locale.py:349: error: Need type annotation for "now"
+ tornado/locale.py:359: error: Unsupported operand types for - ("int" and "timedelta")
+ tornado/locale.py:359: error: Unsupported operand types for - ("float" and "timedelta")
+ tornado/locale.py:359: note: Left operand is of type "Union[int, float, datetime]"
+ tornado/web.py:633: error: Incompatible types in assignment (expression has type "timedelta", variable has type "Union[float, Tuple[Any, ...], datetime, None]")
+ tornado/web.py:663: error: Argument "expires" to "set_cookie" of "RequestHandler" has incompatible type "timedelta"; expected "Union[float, Tuple[Any, ...], datetime, None]"
+ tornado/web.py:2688: error: Argument 2 to "set_header" of "RequestHandler" has incompatible type "timedelta"; expected "Union[bytes, str, int, Integral, datetime]"
+ tornado/web.py:2877: error: Need type annotation for "modified"

bandersnatch (https://github.com/pypa/bandersnatch)
+ src/bandersnatch/utils.py: note: In function "make_time_stamp":
+ src/bandersnatch/utils.py:42: error: <nothing> has no attribute "isoformat"
- src/bandersnatch_storage_plugins/swift.py:297: error: "SwiftPath" has no attribute "_drv"
- src/bandersnatch_storage_plugins/swift.py:298: error: "SwiftPath" has no attribute "_root"
- src/bandersnatch_storage_plugins/swift.py:299: error: "SwiftPath" has no attribute "_parts"
- src/bandersnatch_storage_plugins/swift.py: note: At top level:
- src/bandersnatch_storage_plugins/swift.py:302: error: Unused "type: ignore" comment
+ src/bandersnatch_storage_plugins/swift.py:295: error: Need type annotation for "self"
- src/bandersnatch_storage_plugins/swift.py:309: error: "SwiftPath" has no attribute "_drv"
+ src/bandersnatch_storage_plugins/swift.py:308: error: Need type annotation for "self"
+ src/bandersnatch_storage_plugins/swift.py: note: In member "update_timestamp" of class "SwiftStorage":
- src/bandersnatch_storage_plugins/swift.py:310: error: "SwiftPath" has no attribute "_root"
+ src/bandersnatch_storage_plugins/swift.py:917: error: <nothing> has no attribute "timestamp"
+ src/bandersnatch/mirror.py: note: In member "wrapup_successful_sync" of class "BandersnatchMirror":
+ src/bandersnatch/mirror.py:515: error: Statement is unreachable
- src/bandersnatch_storage_plugins/swift.py:311: error: "SwiftPath" has no attribute "_parts"
- src/bandersnatch_storage_plugins/swift.py: note: At top level:
- src/bandersnatch_storage_plugins/swift.py:314: error: Unused "type: ignore" comment

streamlit (https://github.com/streamlit/streamlit)
+ scripts/add_license_headers.py:44:13: error: <nothing> has no attribute "year"  [attr-defined]
+ lib/streamlit/string_util.py: note: In function "append_date_time_to_string":
+ lib/streamlit/string_util.py:99:11: error: Need type annotation for "now"  [var-annotated]
+ lib/streamlit/string_util.py:102:9: error: Returning Any from function declared to return "str"  [no-any-return]
+ lib/streamlit/config_option.py: note: In member "is_expired" of class "ConfigOption":
+ lib/streamlit/config_option.py:285:15: error: Need type annotation for "now"  [var-annotated]
+ lib/streamlit/config_option.py:286:9: error: Returning Any from function declared to return "bool"  [no-any-return]
+ lib/streamlit/state/session_state.py:70: error: Type application has too few types (2 expected)  [misc]
+ lib/streamlit/elements/time_widgets.py: note: In member "time_input" of class "TimeWidgetsMixin":
+ lib/streamlit/elements/time_widgets.py:92:21: error: <nothing> has no attribute "time"  [attr-defined]
+ lib/streamlit/elements/time_widgets.py: note: In member "date_input" of class "TimeWidgetsMixin":
+ lib/streamlit/elements/time_widgets.py:208:21: error: <nothing> has no attribute "date"  [attr-defined]
+ lib/tests/streamlit/legacy_caching/hashing_test.py: note: In member "test_hashing_broken_code" of class "HashTest":
+ lib/tests/streamlit/legacy_caching/hashing_test.py:226:18: error: Need type annotation for "ctx"  [var-annotated]
+ lib/tests/streamlit/caching/memo_test.py:131:14: error: Need type annotation for "error"  [var-annotated]
+ lib/tests/streamlit/caching/memo_test.py:137:14: error: Need type annotation for "e"  [var-annotated]
+ scripts/pypi_nightly_create_tag.py: note: In function "create_tag":
+ scripts/pypi_nightly_create_tag.py:46:11: error: <nothing> has no attribute "strftime"  [attr-defined]
+ lib/tests/streamlit/time_input_test.py: note: In member "test_just_label" of class "TimeInputTest":
+ lib/tests/streamlit/time_input_test.py:34:59: error: <nothing> has no attribute "time"  [attr-defined]
+ lib/tests/streamlit/text_input_test.py: note: In member "test_input_types" of class "TextInputTest":
+ lib/tests/streamlit/text_input_test.py:69:14: error: Need type annotation for "exc"  [var-annotated]
+ lib/tests/streamlit/streamlit_test.py: note: In member "test_st_image_bad_width" of class "StreamlitAPITest":
+ lib/tests/streamlit/streamlit_test.py:505:14: error: Need type annotation for "ctx"  [var-annotated]
+ lib/tests/streamlit/metric_test.py: note: In member "test_invalid_label" of class "MetricTest":
+ lib/tests/streamlit/metric_test.py:152:14: error: Need type annotation for "exc"  [var-annotated]
+ lib/tests/streamlit/metric_test.py: note: In member "test_invalid_value" of class "MetricTest":
+ lib/tests/streamlit/metric_test.py:162:14: error: Need type annotation for "exc"  [var-annotated]
+ lib/tests/streamlit/metric_test.py: note: In member "test_invalid_delta" of class "MetricTest":
+ lib/tests/streamlit/metric_test.py:172:14: error: Need type annotation for "exc"  [var-annotated]
+ lib/tests/streamlit/metric_test.py: note: In member "test_invalid_delta_color" of class "MetricTest":
+ lib/tests/streamlit/metric_test.py:182:14: error: Need type annotation for "exc"  [var-annotated]
+ lib/tests/streamlit/map_test.py: note: In member "test_missing_column" of class "StMapTest":
+ lib/tests/streamlit/map_test.py:83:14: error: Need type annotation for "ctx"  [var-annotated]
+ lib/tests/streamlit/map_test.py: note: In member "test_nan_exception" of class "StMapTest":
+ lib/tests/streamlit/map_test.py:91:14: error: Need type annotation for "ctx"  [var-annotated]
+ lib/tests/streamlit/form_test.py: note: In member "test_multiple_forms_same_key" of class "FormMarshallingTest":
+ lib/tests/streamlit/form_test.py:197:14: error: Need type annotation for "ctx"  [var-annotated]
+ lib/tests/streamlit/form_test.py: note: In member "test_form_in_form" of class "FormMarshallingTest":
+ lib/tests/streamlit/form_test.py:218:14: error: Need type annotation for "ctx"  [var-annotated]
+ lib/tests/streamlit/form_test.py: note: In member "test_button_in_form" of class "FormMarshallingTest":
+ lib/tests/streamlit/form_test.py:228:14: error: Need type annotation for "ctx"  [var-annotated]
+ lib/tests/streamlit/form_test.py: note: In member "test_submit_button_outside_form" of class "FormSubmitButtonTest":
+ lib/tests/streamlit/form_test.py:250:14: error: Need type annotation for "ctx"  [var-annotated]
+ lib/tests/streamlit/delta_generator_test.py: note: In member "test_nonexistent_method" of class "DeltaGeneratorTest":
+ lib/tests/streamlit/delta_generator_test.py:128:14: error: Need type annotation for "ctx"  [var-annotated]
+ lib/tests/streamlit/delta_generator_test.py: note: In member "test_sidebar_nonexistent_method" of class "DeltaGeneratorTest":
+ lib/tests/streamlit/delta_generator_test.py:136:14: error: Need type annotation for "ctx"  [var-annotated]
+ lib/tests/streamlit/delta_generator_test.py: note: In member "test_duplicate_widget_id_error" of class "DeltaGeneratorTest":
+ lib/tests/streamlit/delta_generator_test.py:168:18: error: Need type annotation for "ctx"  [var-annotated]
+ lib/tests/streamlit/delta_generator_test.py: note: In member "test_unequal_images_and_captions_error" of class "DeltaGeneratorImageTest":
+ lib/tests/streamlit/delta_generator_test.py:585:14: error: Need type annotation for "ctx"  [var-annotated]
+ lib/tests/streamlit/date_input_test.py: note: In member "test_just_label" of class "DateInputTest":
+ lib/tests/streamlit/date_input_test.py:39:65: error: <nothing> has no attribute "date"  [attr-defined]
- lib/tests/streamlit/date_input_test.py:171:16: error: Non-overlapping equality check (left operand type: "Union[date, Tuple[date, ...]]", right operand type: "List[datetime]")  [comparison-overlap]
+ lib/tests/streamlit/date_input_test.py:171:16: error: Non-overlapping equality check (left operand type: "Union[date, Tuple[date, ...]]", right operand type: "List[timedelta]")  [comparison-overlap]
+ lib/tests/streamlit/components_test.py: note: In member "test_register_invalid_path" of class "ComponentRegistryTest":
+ lib/tests/streamlit/components_test.py:191:14: error: Need type annotation for "ctx"  [var-annotated]
+ lib/tests/streamlit/state/session_state_test.py: note: In member "test_date_input_serde" of class "SessionStateSerdeTest":
+ lib/tests/streamlit/state/session_state_test.py:295:20: error: <nothing> has no attribute "date"  [attr-defined]
+ lib/tests/streamlit/state/session_state_test.py: note: In member "test_slider_serde" of class "SessionStateSerdeTest":
+ lib/tests/streamlit/state/session_state_test.py:392:19: error: <nothing> has no attribute "time"  [attr-defined]
+ lib/tests/streamlit/legacy_caching/caching_test.py: note: In member "test_unhashable_type" of class "CacheErrorsTest":
+ lib/tests/streamlit/legacy_caching/caching_test.py:512:14: error: Need type annotation for "cm"  [var-annotated]
+ lib/tests/streamlit/legacy_caching/caching_test.py: note: In member "test_hash_funcs_acceptable_keys" of class "CacheErrorsTest":
+ lib/tests/streamlit/legacy_caching/caching_test.py:568:14: error: Need type annotation for "cm"  [var-annotated]
+ lib/tests/streamlit/legacy_caching/caching_test.py: note: In member "test_user_hash_error" of class "CacheErrorsTest":
+ lib/tests/streamlit/legacy_caching/caching_test.py:585:14: error: Need type annotation for "cm"  [var-annotated]
+ lib/tests/streamlit/commands/page_config_test.py:51:14: error: Need type annotation for "e"  [var-annotated]
+ lib/tests/streamlit/commands/page_config_test.py:80:14: error: Need type annotation for "e"  [var-annotated]
+ lib/tests/streamlit/commands/page_config_test.py:94:14: error: Need type annotation for "e"  [var-annotated]
+ lib/tests/streamlit/caching/cache_errors_test.py:70:14: error: Need type annotation for "cm"  [var-annotated]

paasta (https://github.com/yelp/paasta)
+ paasta_tools/utils.py:1414: error: <nothing> has no attribute "isoformat"
+ paasta_tools/autoscaling/load_boost.py:202: error: <nothing> has no attribute "strftime"
+ paasta_tools/kubernetes_tools.py:2002: error: <nothing> has no attribute "timestamp"
+ paasta_tools/kubernetes_tools.py:2437: error: Need type annotation for "s"
+ paasta_tools/kubernetes_tools.py:2655: error: <nothing> has no attribute "timestamp"
+ paasta_tools/mesos_tools.py:326: error: Need type annotation for "first_status_datetime"
+ paasta_tools/mesos_tools.py:374: error: <nothing> has no attribute "strftime"
+ paasta_tools/cli/cmds/status.py:608: error: Need type annotation for "create_datetime"
+ paasta_tools/cli/cmds/status.py:676: error: Need type annotation for "local_deployed_datetime"
+ paasta_tools/cli/cmds/status.py:940: error: Unsupported left operand type for - (<nothing>)
+ paasta_tools/cli/cmds/status.py:1115: error: Need type annotation for "start_time"
+ paasta_tools/cli/cmds/status.py:1288: error: Need type annotation for "start_datetime"
+ paasta_tools/cli/cmds/status.py:1299: error: Need type annotation for "state"
+ paasta_tools/cli/cmds/status.py:1406: error: <nothing> has no attribute "timestamp"
+ paasta_tools/cli/cmds/status.py:1452: error: Need type annotation for "start_datetime"
+ paasta_tools/cli/cmds/status.py:1474: error: Need type annotation for "timestamp"
+ paasta_tools/cli/cmds/status.py:1512: error: <nothing> has no attribute "timestamp"
+ paasta_tools/cli/cmds/status.py:1519: error: <nothing> has no attribute "timestamp"
+ paasta_tools/cli/cmds/status.py:1644: error: Need type annotation for "create_datetime"
+ paasta_tools/cli/cmds/status.py:1812: error: Unsupported left operand type for - (<nothing>)
+ paasta_tools/cli/cmds/logs.py:1024: error: <nothing> has no attribute "replace"
+ paasta_tools/cli/cmds/logs.py:1192: error: Need type annotation for "end_time"
+ paasta_tools/cli/cmds/logs.py:1223: error: Incompatible types in assignment (expression has type "datetime", variable has type "timedelta")
+ paasta_tools/cli/cmds/logs.py:1223: error: Argument 1 to "localize" of "_UTCclass" has incompatible type "timedelta"; expected "datetime"
+ paasta_tools/cli/cmds/logs.py:1229: error: Incompatible return value type (got "Tuple[timedelta, Any]", expected "Tuple[datetime, datetime]")
+ paasta_tools/cli/cmds/list_deploy_queue.py:168: error: Need type annotation for "datetime_obj"
+ paasta_tools/api/views/instance.py:575: error: <nothing> has no attribute "strftime"

git-revise (https://github.com/mystor/git-revise)
+ gitrevise/odb.py:57: error: Return type "Oid" of "fromhex" incompatible with return type "_T" in supertype "bytes"
+ gitrevise/odb.py:387: error: Need type annotation for "abbrev"
+ gitrevise/odb.py:484: error: Need type annotation for "self"

@AlexWaygood
Copy link
Member Author

Closing this; will open a new PR without lowercase type, since that obviously still causes problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant