Title: Don't report errors inside unannotated functions · Issue #1334 · python/mypy · GitHub
Open Graph Title: Don't report errors inside unannotated functions · Issue #1334 · python/mypy
X Title: Don't report errors inside unannotated functions · Issue #1334 · python/mypy
Description: When typechecking the following file, we give an error: $ cat /tmp/foo.py def f(foo): if foo is not None: dumps = foo.dumps else: from json import dumps $ mypy /tmp/foo.py /tmp/foo.py: note: In function "f": /tmp/foo.py:5: error: Name 'd...
Open Graph Description: When typechecking the following file, we give an error: $ cat /tmp/foo.py def f(foo): if foo is not None: dumps = foo.dumps else: from json import dumps $ mypy /tmp/foo.py /tmp/foo.py: note: In fun...
X Description: When typechecking the following file, we give an error: $ cat /tmp/foo.py def f(foo): if foo is not None: dumps = foo.dumps else: from json import dumps $ mypy /tmp/foo.py /tmp/foo.py: note: In fun...
Opengraph URL: https://github.com/python/mypy/issues/1334
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Don't report errors inside unannotated functions","articleBody":"When typechecking the following file, we give an error:\n\n```\n$ cat /tmp/foo.py\ndef f(foo):\n if foo is not None:\n dumps = foo.dumps\n else:\n from json import dumps\n\n$ mypy /tmp/foo.py\n/tmp/foo.py: note: In function \"f\":\n/tmp/foo.py:5: error: Name 'dumps' already defined\n```\n\nBecause the function `f` doesn't have a type annotation, we ought to let this code be without complaining about it -- that makes it easier to start using mypy in parts of a large file, and pay the cost of fixing up code like this to work with mypy incrementally.\n\n(Thanks to @varenc for reporting this issue -- he tried putting an annotation on one new function in a 3kLOC file with 188 existing functions, and it had this one error which stopped him.)\n","author":{"url":"https://github.com/gnprice","@type":"Person","name":"gnprice"},"datePublished":"2016-04-06T00:00:16Z","url":"https://github.com/python/mypy/issues/1334"}
| 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:f6ffe0bc-9500-980d-7d5c-3f5eb53d8a9e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 809A:356FBF:1D54F2D:277A5FB:6B000809 |
| html-safe-nonce | e69deafb2fc5a1106d2036ec4339699ade4382aedf21de09e33b46c5612caf8f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MDlBOjM1NkZCRjoxRDU0RjJEOjI3N0E1RkI6NkIwMDA4MDkiLCJ2aXNpdG9yX2lkIjoiNjczMzgzODQzMjE0NzA4MTIyNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 359afad5fc4bb66acd0beb2216ea7894904c78015a249f5869eb285cea8771bf |
| hovercard-subject-tag | issue:146143840 |
| 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/1334/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e94babf451090fffd98296171437badbedffbdededd1aaaa76bd9e4d1991dd28/python/mypy/issues/1334 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e94babf451090fffd98296171437badbedffbdededd1aaaa76bd9e4d1991dd28/python/mypy/issues/1334 |
| og:image:alt | When typechecking the following file, we give an error: $ cat /tmp/foo.py def f(foo): if foo is not None: dumps = foo.dumps else: from json import dumps $ mypy /tmp/foo.py /tmp/foo.py: note: In fun... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gnprice |
| 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