Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Remove incorrect handling of isninstance #683

Merged
merged 1 commit into from
Mar 1, 2019
Merged
Changes from all commits
Commits
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
18 changes: 0 additions & 18 deletions src/Analysis/Ast/Impl/Analyzer/Handlers/ConditionalHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,6 @@ public bool HandleIf(IfStatement node) {
someRecognized = true;
}
}

// Handle basic check such as
// if isinstance(value, type):
// return value
// by assigning type to the value unless clause is raising exception.
var ce = node.Tests.FirstOrDefault()?.Test as CallExpression;
if (ce?.Target is NameExpression ne && ne.Name == @"isinstance" && ce.Args.Count == 2) {
var nex = ce.Args[0].Expression as NameExpression;
var name = nex?.Name;
var typeName = (ce.Args[1].Expression as NameExpression)?.Name;
if (name != null && typeName != null) {
var typeId = typeName.GetTypeId();
if (typeId != BuiltinTypeId.Unknown) {
var t = new PythonType(typeName, Module, string.Empty, LocationInfo.Empty, typeId);
Eval.DeclareVariable(name, t, VariableSource.Declaration, nex);
}
}
}
return !someRecognized;
}

Expand Down