Title: Clarify SyntaxWarning with literal comparison · Issue #103492 · python/cpython · GitHub
Open Graph Title: Clarify SyntaxWarning with literal comparison · Issue #103492 · python/cpython
X Title: Clarify SyntaxWarning with literal comparison · Issue #103492 · python/cpython
Description: I had a coworker slightly confused about the following warning, since None is a literal and is not None is idiomatic: >>> 'a' is not None
Open Graph Description: I had a coworker slightly confused about the following warning, since None is a literal and is not None is idiomatic: >>> 'a' is not None
X Description: I had a coworker slightly confused about the following warning, since None is a literal and is not None is idiomatic: >>> 'a' is not None <stdin>:1: SyntaxWarning: "is n...
Opengraph URL: https://github.com/python/cpython/issues/103492
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Clarify SyntaxWarning with literal comparison","articleBody":"I had a coworker slightly confused about the following warning, since None is a literal and `is not None` is idiomatic:\r\n```\r\n\u003e\u003e\u003e 'a' is not None\r\n\u003cstdin\u003e:1: SyntaxWarning: \"is not\" with a literal. Did you mean \"!=\"?\r\nTrue\r\n```\r\nI think this would be better as:\r\n```\r\n\u003e\u003e\u003e 'a' is not None\r\n\u003cstdin\u003e:1: SyntaxWarning: \"is not\" with str literal. Did you mean \"!=\"?\r\nTrue\r\n```\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-103493\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/hauntsaninja","@type":"Person","name":"hauntsaninja"},"datePublished":"2023-04-13T00:45:50.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/103492/cpython/issues/103492"}
| 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:28e5a2f8-9ed4-44e4-c84f-07a6f7c03f4f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9AE4:AA79F:41BCE5:5C79B2:696A0BAB |
| html-safe-nonce | 758c9ac27ce414f8799ed5e3667b09600e6d754b32a64ac16cce8924f5a5be36 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QUU0OkFBNzlGOjQxQkNFNTo1Qzc5QjI6Njk2QTBCQUIiLCJ2aXNpdG9yX2lkIjoiMzQzMzUwNjQ1Mjg3MTQ0OTUxNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 501e0e5fa7ca02706199993188e4d148dc6ef5a9dd9983bb2cc06d408299392d |
| hovercard-subject-tag | issue:1665472547 |
| 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/cpython/103492/issue_layout |
| twitter:image | https://opengraph.githubassets.com/022d86ec21d6b090b61f05a9ac57f6b2dd584b8f1679fff3894bf759e7cc7729/python/cpython/issues/103492 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/022d86ec21d6b090b61f05a9ac57f6b2dd584b8f1679fff3894bf759e7cc7729/python/cpython/issues/103492 |
| og:image:alt | I had a coworker slightly confused about the following warning, since None is a literal and is not None is idiomatic: >>> 'a' is not None |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hauntsaninja |
| hostname | github.com |
| expected-hostname | github.com |
| None | 699227a00bbb7fe1eec276d2ae1c3a93068bc5ba483bd9dc4b2a27a8f4f2f595 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| 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 | 7266b2d935baa1c6474b16dd9feaa5ca30607261 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width