Title: Incremental mode bug for nested ParamSpecs · Issue #14322 · python/mypy · GitHub
Open Graph Title: Incremental mode bug for nested ParamSpecs · Issue #14322 · python/mypy
X Title: Incremental mode bug for nested ParamSpecs · Issue #14322 · python/mypy
Description: Bug Report This bug only occurs on the second run when using incremental mode. When using nested ParamSpecs, the outer ParamSpec (M below) is erroneously equal to the inner ParamSpec (P below). Notably, pyright handles this correctly. To...
Open Graph Description: Bug Report This bug only occurs on the second run when using incremental mode. When using nested ParamSpecs, the outer ParamSpec (M below) is erroneously equal to the inner ParamSpec (P below). Not...
X Description: Bug Report This bug only occurs on the second run when using incremental mode. When using nested ParamSpecs, the outer ParamSpec (M below) is erroneously equal to the inner ParamSpec (P below). Not...
Opengraph URL: https://github.com/python/mypy/issues/14322
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incremental mode bug for nested ParamSpecs","articleBody":"**Bug Report**\r\n\r\nThis bug only occurs on the second run when using incremental mode. When using nested `ParamSpec`s, the outer `ParamSpec` (`M` below) is erroneously equal to the inner `ParamSpec` (`P` below).\r\n\r\nNotably, pyright handles this correctly.\r\n\r\n**To Reproduce**\r\n\r\n```python\r\nfrom __future__ import annotations\r\n\r\nfrom typing import Callable, Concatenate, Generic, ParamSpec, TypeVar\r\n\r\n\r\nclass ABase:\r\n ...\r\n\r\n\r\nclass ADerived(ABase):\r\n def __init__(self, a_param_1: float) -> None:\r\n super().__init__()\r\n self.a_1 = a_param_1\r\n\r\n\r\nM = ParamSpec(\"M\")\r\nP = ParamSpec(\"P\")\r\nR = TypeVar(\"R\", bound=ABase)\r\n\r\n\r\nclass B(Generic[P, R]):\r\n def __init__(\r\n self,\r\n a_class: Callable[P, R],\r\n b_param_1: str,\r\n *args: P.args,\r\n **kwargs: P.kwargs,\r\n ) -> None:\r\n self.a = a_class(*args, **kwargs)\r\n self.b_1 = b_param_1\r\n\r\n @classmethod\r\n def build(\r\n cls: Callable[Concatenate[Callable[P, R], M], B[P, R]], \r\n a_class: Callable[P, R]\r\n ) -> Callable[M, B[P, R]]:\r\n\r\n def new_constructor(\r\n *args: M.args,\r\n **kwargs: M.kwargs,\r\n ) -> B[P, R]:\r\n return cls(a_class, *args, **kwargs)\r\n\r\n return new_constructor\r\n\r\n\r\nBADerived = B.build(ADerived)\r\n\r\nreveal_type(BADerived) # note): Revealed type is \"def (a_param_1: builtins.float) -> B[[a_param_1: builtins.float], ADerived]\"\r\n\r\nb_a_derived_1 = B(ADerived, \"my_str\", 1.0) # OK\r\nb_a_derived_2 = BADerived( # [call-arg] error: Too many arguments\r\n \"my_str\", 1.0 # [arg-type] error: Argument 1 has incompatible type \"str\"; expected \"float\"\r\n)\r\n\r\n```\r\n\r\n**Expected Behavior**\r\n\r\nI expect the signature of `BADerived` to include `b_param_1`, like this:\r\n\r\n```\r\nmypy_nested_paramspec.py:49: note: Revealed type is \"def (b_param_1: builtins.str, a_param_1: builtins.float) -> mypy_nested_paramspec.B[[a_param_1: builtins.float], ADerived]\"\r\n```\r\n\r\nI also expect that calls to `BADerived` with the correct parameter count and types do not raise any errors.\r\n\r\n**Actual Behavior**\r\n\r\n```\r\nmypy_nested_paramspec.py:49: note: Revealed type is \"def (a_param_1: builtins.float) -> mypy_nested_paramspec.B[[a_param_1: builtins.float], mypy_nested_paramspec.ADerived]\"\r\nmypy_nested_paramspec.py:52: error: Too many arguments [call-arg]\r\nmypy_nested_paramspec.py:53: error: Argument 1 has incompatible type \"str\"; expected \"float\" [arg-type]\r\n```\r\n\r\n**Your Environment**\r\n\r\n* Mypy version used: mypy 0.991 (compiled: yes)\r\n* Python version used: 3.10.6","author":{"url":"https://github.com/ringohoffman","@type":"Person","name":"ringohoffman"},"datePublished":"2022-12-20T08:42:03Z","url":"https://github.com/python/mypy/issues/14322"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e31e30c1-d991-fa4d-0e6e-5452a35b7298 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DAD4:18FDF5:102D98:15CA4F:6B001D82 |
| html-safe-nonce | 969e97d7d978b5c03d659636f7a2b3c47ee01b60d491e3a8d7b551649ab74c76 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQUQ0OjE4RkRGNToxMDJEOTg6MTVDQTRGOjZCMDAxRDgyIiwidmlzaXRvcl9pZCI6IjUzNTI3NDM4NTIxODI2MDkyODIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | beaf1766fd55107be7ac12a1a37c6e8c827de47ecb1127b1a5d8eb643d16dcab |
| hovercard-subject-tag | issue:1504186422 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/mypy/14322/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b6b80fabcf25c452de1dbc676e440ebe82f3b72b4aaafdf242109e6ac146fc92/python/mypy/issues/14322 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b6b80fabcf25c452de1dbc676e440ebe82f3b72b4aaafdf242109e6ac146fc92/python/mypy/issues/14322 |
| og:image:alt | Bug Report This bug only occurs on the second run when using incremental mode. When using nested ParamSpecs, the outer ParamSpec (M below) is erroneously equal to the inner ParamSpec (P below). Not... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ringohoffman |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/mypy git https://github.com/python/mypy.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 7053637 |
| octolytics-dimension-repository_nwo | python/mypy |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7053637 |
| octolytics-dimension-repository_network_root_nwo | python/mypy |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width