question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Forbid chaining `is`

See original GitHub issue

Rule request

Thesis

Forbid ast.Is in ast.Compare.ops when it’s size is not zero. For example:

a = None
a is None           # True, as expected
a is None is True   # False 🤔
a is None == True   # False 🤔
a is None is None   # True 🤯 

Reasoning

From the AST perspective, is is an operator and can be chained. That can lead to unexpected results when the author wanted to compare the result of a is b operation. Instead, Python will chain the operations and compare the last argument of the previous operation.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
lensvolcommented, Oct 2, 2022

@sobolevn You know me, can’t stay away from a free T-shirt 😃

1reaction
sobolevncommented, Oct 1, 2022

Hi, @lensvol! Happy to see you 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Chaining Is Prohibited in the Following Communities - PETA
This ordinance prohibits dogs from being chained to a fixed point. Under this ordinance, dogs are allowed to be confined by a trolley...
Read more >
Table of State Dog Tether Laws
Tethering or chaining a dog simply means that a person ties a dog with a rope, ... California prohibits tethering a dog to...
Read more >
The Dangers of Dog Chaining
“Dog chaining” describes a practice in which dog owners tether their dogs outdoors to a stationary object for extended periods of time.
Read more >
Another state bans chaining dogs without 'adequate shelter'
The new law bans tethering dogs unless owners provide “adequate shelter,” a space that is comfortable for the dog to move around in, ......
Read more >
New Texas law to ban chaining dogs | News | athensreview.com
This is great news for dogs seen dragging the neighborhood with a huge towing chain or a collar that digs into their skin....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found