Title: :bug: Methods converted to `staticmethod`s using a decorator not treated as `staticmethod`s · Issue #13434 · python/mypy · GitHub
Open Graph Title: :bug: Methods converted to `staticmethod`s using a decorator not treated as `staticmethod`s · Issue #13434 · python/mypy
X Title: :bug: Methods converted to `staticmethod`s using a decorator not treated as `staticmethod`s · Issue #13434 · python/mypy
Description: Bug Report The @staticmethod decorator only appears to work with MyPy when used as a decorator. For example, the following code works: class MyClass: @staticmethod def my_method(): ... However, the following code does not work: from typi...
Open Graph Description: Bug Report The @staticmethod decorator only appears to work with MyPy when used as a decorator. For example, the following code works: class MyClass: @staticmethod def my_method(): ... However, the...
X Description: Bug Report The @staticmethod decorator only appears to work with MyPy when used as a decorator. For example, the following code works: class MyClass: @staticmethod def my_method(): ... However, the...
Opengraph URL: https://github.com/python/mypy/issues/13434
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":":bug: Methods converted to `staticmethod`s using a decorator not treated as `staticmethod`s","articleBody":"**Bug Report**\r\nThe `@staticmethod` decorator only appears to work with MyPy when used as a decorator.\r\n\r\nFor example, the following code works:\r\n```python\r\nclass MyClass:\r\n @staticmethod\r\n def my_method():\r\n ...\r\n```\r\n\r\nHowever, the following code does not work:\r\n```python\r\nfrom typing import Callable\r\n\r\n\r\ndef make_staticmethod(func: Callable, /) -> staticmethod:\r\n return staticmethod(func)\r\n\r\nclass MyClass:\r\n @make_staticmethod\r\n def my_method():\r\n ...\r\n```\r\n\r\nThe above code produces the following error:\r\n```sh\r\nerror: Method must have at least one argument\r\n``` \r\n\r\n**To Reproduce**\r\n1. Run MyPy against the non-working example shown above\r\n\r\n**Expected Behavior**\r\nMyPy sees that the decorator returns a `staticmethod` and proceeds to treat `MyClass.my_method` as a `staticmethod`\r\n\r\n**Actual Behavior**\r\nMyPy produces the following error:\r\n```sh\r\nerror: Method must have at least one argument\r\n``` \r\nThe above error implies that MyPy is not treating the method as a `staticmethod`.\r\n\r\n**Your Environment**\r\n- Mypy version used: **0.971**\r\n- Mypy command-line flags: ***N/A***\r\n- Mypy configuration options from `mypy.ini` (and other config files): ***N/A***\r\n- Python version used: **3.8.10**\r\n- Operating system and version: **Linux Mint 20.3 x86_64**","author":{"url":"https://github.com/tombulled","@type":"Person","name":"tombulled"},"datePublished":"2022-08-16T12:46:58Z","url":"https://github.com/python/mypy/issues/13434"}
| 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:9f165a48-df28-f0c3-84b9-8353b8de712f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AF44:15E670:60CE1:85DEA:6B004EBB |
| html-safe-nonce | b4e16b6e7c1ce8a6c8c1782f1a16ec51a15166a5396536328661141431032175 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRjQ0OjE1RTY3MDo2MENFMTo4NURFQTo2QjAwNEVCQiIsInZpc2l0b3JfaWQiOiI1OTc2NzEzNjUxNTE4NzIxNzIzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 5dc3039c87bd7c8519c6726c75ea8dd1ba50f29911eea39588ff466a0e0113cd |
| hovercard-subject-tag | issue:1340302451 |
| 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/13434/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7ab8e8293a7e06a27bdeee58e8e43d8da08e91b8b21fbbcf6301afc0d6f458ee/python/mypy/issues/13434 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7ab8e8293a7e06a27bdeee58e8e43d8da08e91b8b21fbbcf6301afc0d6f458ee/python/mypy/issues/13434 |
| og:image:alt | Bug Report The @staticmethod decorator only appears to work with MyPy when used as a decorator. For example, the following code works: class MyClass: @staticmethod def my_method(): ... However, the... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tombulled |
| hostname | github.com |
| expected-hostname | github.com |
| None | f9517bf360d46638a1e5e7daee7158842fe5ef43c9000afa0e127564a7c2f39b |
| 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 | b27c5dde30676028abd5c5fc53ce5c9b625f8281 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width