Title: Crash when using ParamSpec · Issue #17825 · python/mypy · GitHub
Open Graph Title: Crash when using ParamSpec · Issue #17825 · python/mypy
X Title: Crash when using ParamSpec · Issue #17825 · python/mypy
Description: Crash Report I'm developing an cache decorator that uses ParamSpec to be as generic as possible. There's a slight bug in my code (I used Sequence where I should have used Paramspec.args), but I feel that shouldn't have led to a crash. Th...
Open Graph Description: Crash Report I'm developing an cache decorator that uses ParamSpec to be as generic as possible. There's a slight bug in my code (I used Sequence where I should have used Paramspec.args), but I fee...
X Description: Crash Report I'm developing an cache decorator that uses ParamSpec to be as generic as possible. There's a slight bug in my code (I used Sequence where I should have used Paramspec.args), b...
Opengraph URL: https://github.com/python/mypy/issues/17825
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Crash when using ParamSpec","articleBody":"**Crash Report**\r\n\r\nI'm developing an cache decorator that uses ParamSpec to be as generic as possible.\r\nThere's a slight bug in my code (I used `Sequence` where I should have used `Paramspec.args`), but I feel that shouldn't have led to a crash. There might actually be legitimate usecases for the incorrect code I wrote.\r\n\r\n**Traceback**\r\n\r\n```\r\nmypy_bug_test.py:22: error: INTERNAL ERROR -- Please try using mypy master on GitHub:\r\nhttps://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build\r\nPlease report a bug at https://github.com/python/mypy/issues\r\nversion: 1.11.2\r\nTraceback (most recent call last):\r\n File \"mypy/checkexpr.py\", line 5822, in accept\r\n File \"mypy/checkexpr.py\", line 480, in visit_call_expr\r\n File \"mypy/checkexpr.py\", line 614, in visit_call_expr_inner\r\n File \"mypy/checkexpr.py\", line 1467, in check_call_expr_with_callee_type\r\n File \"mypy/checkexpr.py\", line 1597, in check_call\r\n File \"mypy/checkexpr.py\", line 1561, in check_call\r\n File \"mypy/checkexpr.py\", line 1746, in check_callable_call\r\n File \"mypy/checkexpr.py\", line 2062, in infer_function_type_arguments\r\n File \"mypy/checkexpr.py\", line 2268, in get_arg_infer_passes\r\n File \"mypy/subtypes.py\", line 1248, in find_member\r\n File \"mypy/subtypes.py\", line 1383, in find_node_type\r\n File \"mypy/expandtype.py\", line 114, in expand_type_by_instance\r\n File \"mypy/expandtype.py\", line 69, in expand_type\r\n File \"mypy/types.py\", line 2004, in accept\r\n File \"mypy/expandtype.py\", line 408, in visit_callable_type\r\n File \"mypy/expandtype.py\", line 500, in expand_types\r\n File \"mypy/types.py\", line 769, in accept\r\n File \"mypy/expandtype.py\", line 264, in visit_param_spec\r\nAssertionError: \r\nmypy_bug_test.py:22: : note: use --pdb to drop into pdb\r\n```\r\n\r\n**To Reproduce**\r\n\r\nThis is how far I've managed to whitle my testcase down:\r\n\r\n```python\r\nfrom collections.abc import Callable, Sequence\r\nimport functools\r\nfrom typing import Generic, ParamSpec, TypeVar\r\n\r\nP = ParamSpec(\"P\")\r\nR = TypeVar(\"R\")\r\n\r\nclass DecoratorImplementation(Generic[P, R]):\r\n def __init__(self,\r\n fn: Callable[P, Sequence[R]], param):\r\n self.fn = fn\r\n self.param = param\r\n\r\n def __call__(self, *args: Sequence, **kwargs: P.kwargs):\r\n def wrapper(*args, **kwargs):\r\n return self.fn(*args, **kwargs)\r\n return wrapper\r\n\r\ndef decorator(func, param):\r\n\r\n def decorator_inner(fn):\r\n return functools.wraps(fn)(DecoratorImplementation(fn, param))\r\n\r\n return decorator_inner\r\n```\r\n\r\n**Your Environment**\r\n\r\nOperating system: Debian Bookworm, python 3.11, virtualenv\r\n\r\nmypy versions tested: \r\n* **mypy 1.11.2 (compiled: yes)** (affected) :red_circle: \r\n* **mypy 1.10.0 (compiled: yes)** (affected) :red_circle: \r\n* **mypy 1.9.0 (compiled: yest)** (NOT affected) :green_circle: \r\n\r\npyproject.toml:\r\n```toml\r\n[tool.mypy]\r\npython_version = \"3.11\"\r\nignore_missing_imports = true\r\nshow_error_codes = true\r\ncheck_untyped_defs = true\r\nexclude = \"tests/.*\\\\.py\"\r\n\r\n[[tool.mypy.overrides]]\r\nmodule = \"internal.config_py.*\"\r\n# lots of dict-heavy code which isn't typed at all.\r\nignore_errors = true\r\n```","author":{"url":"https://github.com/kvdveer","@type":"Person","name":"kvdveer"},"datePublished":"2024-09-25T10:13:42Z","url":"https://github.com/python/mypy/issues/17825"}
| 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:edce6033-8692-596c-acb5-018f6e790b40 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9D96:3AAC7B:E503A0:12B0D6C:6AFFFB9A |
| html-safe-nonce | 64da9ee30a1e961b70fe133b8ccae0dcc9648a1a8201cb93c0a06136626197d5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RDk2OjNBQUM3QjpFNTAzQTA6MTJCMEQ2Qzo2QUZGRkI5QSIsInZpc2l0b3JfaWQiOiI5ODMxMjk3MTQzMTcwNTQ5OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 38a8bc26881057a2097f047f5024b7a8b1ee563ad143349e8769595886e326a6 |
| hovercard-subject-tag | issue:2547566306 |
| 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/17825/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7c36e75efd85480753e19ef11f10e4e8a1504c67e3bde0bacf735a2ac9b78892/python/mypy/issues/17825 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7c36e75efd85480753e19ef11f10e4e8a1504c67e3bde0bacf735a2ac9b78892/python/mypy/issues/17825 |
| og:image:alt | Crash Report I'm developing an cache decorator that uses ParamSpec to be as generic as possible. There's a slight bug in my code (I used Sequence where I should have used Paramspec.args), but I fee... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kvdveer |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729 |
| 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 | 16a11879678aaf97e2a42c33ee70830aa084fa37 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width