Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support "is None" constraints from if statements during inference #1189

Merged
merged 27 commits into from
Jan 6, 2023
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
159af87
Support "is None" constraints from if statements during inference
david-yz-liu Aug 28, 2021
1c5b4b3
Merge branch 'main' into constraint-checking
Pierre-Sassoulas Dec 19, 2021
4dffa4d
Merge branch 'main' of https://github.com/PyCQA/astroid into constrai…
DanielNoord Mar 21, 2022
4828797
Changes
DanielNoord Mar 21, 2022
c39baff
Some typing
DanielNoord Mar 21, 2022
b54d841
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 21, 2022
de4c318
Some changes to typing and removal of dead code
DanielNoord Mar 21, 2022
3da1c83
Fix on python 3.7
DanielNoord Mar 21, 2022
7fe82e6
Fix import
DanielNoord Mar 21, 2022
fc4156e
Add abstractness
DanielNoord Mar 21, 2022
55bb33f
Update ChangeLog
Pierre-Sassoulas Mar 22, 2022
8a3b443
Simplify expression NoneConstraint.match
david-yz-liu Mar 23, 2022
5b86d5a
Merge remote-tracking branch 'upstream/main' into constraint-checking
david-yz-liu Jun 17, 2022
e032c0b
move constraint.py into submodule, and small fixes
david-yz-liu Jun 17, 2022
c1268a2
Fix imports and __all__
david-yz-liu Jun 17, 2022
7d0b6b2
Fix Union usage in type definition
david-yz-liu Jun 17, 2022
f963723
Add __future__ import to unittest_constraint.py
david-yz-liu Jun 17, 2022
21e4cf9
Merge remote-tracking branch 'upstream/main' into constraint-checking
david-yz-liu Jul 25, 2022
65c3c55
Updates based on review
david-yz-liu Jul 25, 2022
f6e001b
Use Self
DanielNoord Nov 20, 2022
5da24fe
Use InferenceResult
DanielNoord Nov 20, 2022
b46f001
Don't check None is
DanielNoord Nov 20, 2022
409543b
Use frozenset
DanielNoord Nov 20, 2022
316ba46
Also accept Proxy
DanielNoord Nov 20, 2022
dabf0e9
Use an Iterator
DanielNoord Nov 20, 2022
f70fbad
Merge branch 'main' into constraint-checking
Pierre-Sassoulas Nov 30, 2022
46c056f
Merge remote-tracking branch 'origin/main' into constraint-checking
Pierre-Sassoulas Jan 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify expression NoneConstraint.match
david-yz-liu committed Mar 23, 2022
commit 8a3b44322aa5874aa78fa98f5375a97a937d6267
7 changes: 1 addition & 6 deletions astroid/constraint.py
Original file line number Diff line number Diff line change
@@ -75,12 +75,7 @@ def satisfied_by(
if inferred is util.Uninferable:
return True

if self.negate and matches(inferred, nodes.Const(None)):
return False
if not self.negate and not matches(inferred, nodes.Const(None)):
return False

return True
return self.negate ^ matches(inferred, nodes.Const(None))


def matches(node1: nodes.NodeNG, node2: nodes.NodeNG) -> bool: