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

Sync typeshed #11600

Merged
merged 3 commits into from
Nov 23, 2021
Merged

Sync typeshed #11600

merged 3 commits into from
Nov 23, 2021

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Nov 23, 2021

Source commit:
python/typeshed@2445edd

@sobolevn
Copy link
Member

After this is merged, we can rerun #11585 to make sure it is not failing anymore.
This PR should fix ClassVar problem we had: python/typeshed#6348

@github-actions
Copy link
Contributor

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

freqtrade (https://github.com/freqtrade/freqtrade.git)
- freqtrade/strategy/informative_decorator.py:56: error: Need type annotation for "informative_pairs"

pip (https://github.com/pypa/pip.git)
+ src/pip/_internal/commands/debug.py:70: error: Value of type variable "AnyStr" of "dirname" cannot be "Optional[str]"
+ src/pip/_internal/commands/debug.py:70: error: List item 0 has incompatible type "Optional[str]"; expected "str"

flake8 (https://github.com/pycqa/flake8.git)
- src/flake8/plugins/manager.py:508: error: Need type annotation for "plugins"
- src/flake8/plugins/manager.py:517: error: Need type annotation for "plugins"
- src/flake8/plugins/manager.py:526: error: Need type annotation for "plugins"

pydantic (https://github.com/samuelcolvin/pydantic.git)
+ pydantic/class_validators.py:57: error: Missing type parameters for generic type "classmethod"  [type-arg]
+ pydantic/class_validators.py:84: error: Missing type parameters for generic type "classmethod"  [type-arg]
+ pydantic/class_validators.py:100: error: Missing type parameters for generic type "classmethod"  [type-arg]
+ pydantic/class_validators.py:107: error: Missing type parameters for generic type "classmethod"  [type-arg]
+ pydantic/class_validators.py:113: error: Missing type parameters for generic type "classmethod"  [type-arg]
+ pydantic/class_validators.py:125: error: Missing type parameters for generic type "classmethod"  [type-arg]
+ pydantic/class_validators.py:135: error: Missing type parameters for generic type "classmethod"  [type-arg]
+ pydantic/class_validators.py:328: error: Missing type parameters for generic type "classmethod"  [type-arg]
+ pydantic/main.py:869: error: Missing type parameters for generic type "classmethod"  [type-arg]
+ pydantic/main.py:882: error: Missing type parameters for generic type "classmethod"  [type-arg]
+ pydantic/main.py:894: error: Missing type parameters for generic type "classmethod"  [type-arg]

core (https://github.com/home-assistant/core.git)
+ homeassistant/components/http/forwarded.py:91: error: Unused "type: ignore" comment
+ homeassistant/auth/mfa_modules/__init__.py:136: error: Unused "type: ignore" comment
+ homeassistant/auth/mfa_modules/__init__.py:171: error: Unused "type: ignore" comment
+ homeassistant/auth/providers/__init__.py:145: error: Unused "type: ignore" comment
+ homeassistant/auth/providers/__init__.py:178: error: Unused "type: ignore" comment
+ homeassistant/config.py:648: error: Unused "type: ignore" comment
+ homeassistant/config.py:651: error: Unused "type: ignore" comment
+ homeassistant/config.py:662: error: Unused "type: ignore" comment
+ homeassistant/config.py:672: error: Unused "type: ignore" comment
+ homeassistant/config.py:673: error: Unused "type: ignore" comment
+ homeassistant/config.py:753: error: Unused "type: ignore" comment
+ homeassistant/config.py:895: error: Unused "type: ignore" comment
+ homeassistant/setup.py:241: error: Unused "type: ignore" comment
+ homeassistant/setup.py:246: error: Unused "type: ignore" comment
+ homeassistant/helpers/check_config.py:161: error: Unused "type: ignore" comment
+ homeassistant/config_entries.py:310: error: Unused "type: ignore" comment
+ homeassistant/config_entries.py:449: error: Unused "type: ignore" comment
+ homeassistant/config_entries.py:488: error: Unused "type: ignore" comment
+ homeassistant/config_entries.py:525: error: Unused "type: ignore" comment
+ homeassistant/helpers/condition.py:929: error: Unused "type: ignore" comment
+ homeassistant/helpers/condition.py:977: error: Unused "type: ignore" comment
+ homeassistant/helpers/script.py:260: error: Unused "type: ignore" comment
+ homeassistant/helpers/script.py:262: error: Unused "type: ignore" comment
+ homeassistant/helpers/script.py:269: error: Unused "type: ignore" comment
+ homeassistant/scripts/__init__.py:67: error: Unused "type: ignore" comment
+ homeassistant/helpers/reload.py:81: error: Unused "type: ignore" comment
+ homeassistant/helpers/reload.py:82: error: Unused "type: ignore" comment
+ homeassistant/components/device_tracker/legacy.py:241: error: Unused "type: ignore" comment
+ homeassistant/components/device_tracker/legacy.py:246: error: Unused "type: ignore" comment
+ homeassistant/components/device_tracker/legacy.py:251: error: Unused "type: ignore" comment
+ homeassistant/components/device_tracker/legacy.py:256: error: Unused "type: ignore" comment
+ homeassistant/components/notify/legacy.py:61: error: Unused "type: ignore" comment
+ homeassistant/components/notify/legacy.py:66: error: Unused "type: ignore" comment

streamlit (https://github.com/streamlit/streamlit.git)
+ lib/streamlit/script_runner.py:432: error: Unused "type: ignore" comment
+ lib/streamlit/script_runner.py:439: error: Unused "type: ignore" comment

werkzeug (https://github.com/pallets/werkzeug.git)
- src/werkzeug/local.py:123: error: Need type annotation for "rv"
+ tests/test_wrappers.py:856: error: Function is missing a return type annotation

ibis (https://github.com/ibis-project/ibis.git)
+ ibis/backends/tests/base.py:82: error: Argument 1 to "Path" has incompatible type "Union[str, None, Any]"; expected "Union[str, PathLike[str]]"
- ibis/backends/tests/conftest.py:45: error: Module has no attribute "TestConf"

pandas (https://github.com/pandas-dev/pandas.git)
+ pandas/core/arrays/sparse/array.py:1550: error: Cannot call function of unknown type  [operator]
- pandas/io/stata.py:2598: error: Need type annotation for "convert_strl"  [var-annotated]

arviz (https://github.com/arviz-devs/arviz.git)
+ arviz/data/io_pymc3_3x.py:47: error: Unused "type: ignore" comment
+ arviz/data/io_pymc3_3x.py:48: error: Unused "type: ignore" comment
- examples/bokeh/bokeh_plot_compare.py:15: error: Call to untyped function "plot_compare" in typed context
- examples/bokeh/bokeh_plot_bpv_tstat.py:9: error: Call to untyped function "load_arviz_data" in typed context
- examples/bokeh/bokeh_plot_bpv_tstat.py:10: note: (Skipping most remaining errors due to unresolved imports or missing stubs; fix these first)
+ examples/bokeh/bokeh_plot_compare.py:15: note: (Skipping most remaining errors due to unresolved imports or missing stubs; fix these first)

aiohttp (https://github.com/aio-libs/aiohttp.git)
+ aiohttp/helpers.py:808: error: Unused "type: ignore" comment

sphinx (https://github.com/sphinx-doc/sphinx.git)
+ sphinx/util/inspect.py: note: In function "unwrap_all":
+ sphinx/util/inspect.py:137:19: error: Item "FunctionType" of "Union[FunctionType, FunctionType, MethodType, BuiltinFunctionType, BuiltinFunctionType]" has no attribute "__wrapped__"
+ sphinx/util/inspect.py:137:19: error: Item "MethodType" of "Union[FunctionType, FunctionType, MethodType, BuiltinFunctionType, BuiltinFunctionType]" has no attribute "__wrapped__"
+ sphinx/util/inspect.py:137:19: error: Item "BuiltinFunctionType" of "Union[FunctionType, FunctionType, MethodType, BuiltinFunctionType, BuiltinFunctionType]" has no attribute "__wrapped__"
+ sphinx/environment/__init__.py:624: error: Unused "type: ignore" comment
+ sphinx/writers/manpage.py:110: error: Unused "type: ignore" comment
- sphinx/util/requests.py: note: In function "is_ssl_error":
- sphinx/util/requests.py:54:16: error: Need type annotation for "args"
- sphinx/ext/napoleon/docstring.py: note: In member "_lookup_annotation" of class "GoogleDocstring":
- sphinx/ext/napoleon/docstring.py:864:31: error: Need type annotation for "localns"
- sphinx/ext/viewcode.py: note: In function "env_purge_doc":
- sphinx/ext/viewcode.py:161:15: error: Need type annotation for "modules"

paasta (https://github.com/yelp/paasta.git)
- paasta_tools/kubernetes_tools.py:2106: error: Need type annotation for "stream_lines"

pylint (https://github.com/pycqa/pylint.git)
- pylint/pyreverse/inspector.py:184: error: Need type annotation for "specializations"  [var-annotated]
+ pylint/checkers/utils.py:326: error: Unused "type: ignore" comment
+ pylint/checkers/utils.py:326: error: Module has no attribute "__iter__" (not iterable)  [attr-defined]
- pylint/checkers/variables.py:1781: error: Need type annotation for "elements"  [var-annotated]
- pylint/checkers/typecheck.py:1378: error: Need type annotation for "already_filled_keywords"  [var-annotated]

pyppeteer (https://github.com/pyppeteer/pyppeteer.git)
- pyppeteer/network_manager.py:157: error: No overload variant of "get" of "Mapping" matches argument type "str"
- pyppeteer/network_manager.py:157: note: Possible overload variants:
- pyppeteer/network_manager.py:157: note:     def get(self, key: <nothing>) -> None
- pyppeteer/network_manager.py:157: note:     def [_T] get(self, key: <nothing>, default: _T) -> _T
- pyppeteer/network_manager.py:158: error: No overload variant of "get" of "Mapping" matches argument type "str"
- pyppeteer/network_manager.py:158: note: Possible overload variants:
- pyppeteer/network_manager.py:158: note:     def get(self, key: <nothing>) -> None
- pyppeteer/network_manager.py:158: note:     def [_T] get(self, key: <nothing>, default: _T) -> _T

rich (https://github.com/willmcgugan/rich.git)
+ rich/traceback.py:249: error: Value of type variable "AnyStr" of "dirname" cannot be "Optional[str]"
+ rich/traceback.py:252: error: Value of type variable "AnyStr" of "normpath" cannot be "Optional[str]"
+ rich/traceback.py:252: error: Value of type variable "AnyStr" of "abspath" cannot be "Optional[str]"
+ rich/traceback.py:253: error: Argument 1 to "append" of "list" has incompatible type "Optional[str]"; expected "str"

anyio (https://github.com/agronholm/anyio.git)
+ src/anyio/_core/_eventloop.py:56: error: Unused "type: ignore" comment

edgedb (https://github.com/edgedb/edgedb.git)
- edb/common/parametric.py:150:36: error: Need type annotation for "base_non_type_params"
- edb/edgeql/declarative.py:919:23: error: Need type annotation for "ast_subcommands"
- edb/pgsql/compiler/relctx.py:94:28: error: Need type annotation for "view_path_id_map"
- edb/server/connpool/pool.py:526:16: error: No overload variant of "get" of "Mapping" matches argument type "str"
- edb/server/connpool/pool.py:526:16: note: Possible overload variants:
- edb/server/connpool/pool.py:526:16: note:     def get(self, key: <nothing>) -> None
- edb/server/connpool/pool.py:526:16: note:     def [_T] get(self, key: <nothing>, default: _T) -> _T

pytest (https://github.com/pytest-dev/pytest.git)
+ src/_pytest/pathlib.py:542: error: Item "None" of "Optional[str]" has no attribute "endswith"  [union-attr]
+ src/_pytest/pathlib.py:543: error: Value of type "Optional[str]" is not indexable  [index]
+ src/_pytest/pathlib.py:544: error: Item "None" of "Optional[str]" has no attribute "endswith"  [union-attr]
+ src/_pytest/pathlib.py:545: error: Value of type "Optional[str]" is not indexable  [index]
+ src/_pytest/pathlib.py:548: error: Argument 2 to "_is_same" has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ src/_pytest/config/__init__.py:1440: error: Argument 1 to "Path" has incompatible type "Optional[str]"; expected "Union[str, PathLike[str]]"  [arg-type]
- src/_pytest/mark/structures.py:365: error: Need type annotation for "mark_list"  [var-annotated]
- src/_pytest/fixtures.py:1323: error: Unexpected keyword argument "ids" for "FixtureFunctionMarker"  [call-arg]
- src/_pytest/fixtures.py:1323: error: Unexpected keyword argument "name" for "FixtureFunctionMarker"  [call-arg]
- src/_pytest/fixtures.py:1468: note: (Skipping most remaining errors due to unresolved imports or missing stubs; fix these first)

@JukkaL
Copy link
Collaborator Author

JukkaL commented Nov 23, 2021

I checked some of the new messages, and the new errors look legitimate -- mostly about __file__ possibly being None.

@JukkaL JukkaL merged commit 4996d57 into master Nov 23, 2021
@JukkaL JukkaL deleted the typeshed branch November 23, 2021 14:02
@hauntsaninja
Copy link
Collaborator

Legitimate, sure, but I checked and the __file__ warnings are in practice false positives: python/typeshed#6186 (comment)

@JukkaL
Copy link
Collaborator Author

JukkaL commented Nov 25, 2021

In some cases where optional types have caused false positives, we've used types like str | Any. I don't have a strong opinion on this. In any case any change should be made to typeshed first.

@intgr
Copy link
Contributor

intgr commented Nov 30, 2021

This PR seems to cause regression #11646.

# Mixin methods
@overload
def get(self, key: _KT) -> _VT_co | None: ...
@overload
def get(self, key: _KT, default: _VT_co | _T) -> _VT_co | _T: ...
def get(self, __key: _KT, __default: _VT_co | _T) -> _VT_co | _T: ...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I see, this is the cause of #11646.

The default= argument might not apply to every Mapping.get, but it does work with dict. So maybe there should be special handling for dict.get?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doh. My bad, it dict.get() does not support keyword arguments, the original code was instead using QueryDict from Django.

So I suppose this should be solved in django-stubs instead.

tushar-deepsource pushed a commit to DeepSourceCorp/mypy that referenced this pull request Jan 20, 2022
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.

4 participants