Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions src/Analysis/Engine/Impl/Values/BoundMethodInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public override IAnalysisSet Call(Node node, AnalysisUnit unit, IAnalysisSet[] a
public override IPythonProjectEntry DeclaringModule => Function.DeclaringModule;
public override int DeclaringVersion => Function.DeclaringVersion;
public override IEnumerable<ILocationInfo> Locations => Function.Locations;
public override BuiltinTypeId TypeId => BuiltinTypeId.Function;

public IEnumerable<KeyValuePair<string, string>> GetRichDescription() {
if (Push()) {
Expand Down
2 changes: 1 addition & 1 deletion src/Analysis/Engine/Impl/Values/BuiltinMethodInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public override string Documentation {
return _doc;
}
}

public override BuiltinTypeId TypeId => BuiltinTypeId.BuiltinFunction;
public override PythonMemberType MemberType => _memberType;
public override string Name => _function.Name;
public override ILocatedMember GetLocatedMember() => _function as ILocatedMember;
Expand Down
23 changes: 22 additions & 1 deletion src/Analysis/Engine/Test/AnalysisTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2425,7 +2425,7 @@ def __invert__(self):


[TestMethod, Priority(0)]
public async Task TrueDividePython3X() {
public async Task TrueDividePython35() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can still have a one test, but provide version in parameter, similar to OverrideCompletions3X

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point

var text = @"
class C:
def __truediv__(self, other):
Expand All @@ -2445,6 +2445,27 @@ def __rtruediv__(self, other):
}
}

[TestMethod, Priority(0)]
public async Task TrueDividePython36() {
var text = @"
class C:
def __truediv__(self, other):
return 42
def __rtruediv__(self, other):
return 3.0

a = C()
b = a / 'abc'
c = 'abc' / a
";

using (var server = await CreateServerAsync(PythonVersions.Required_Python36X)) {
var analysis = await server.OpenDefaultDocumentAndGetAnalysisAsync(text);
analysis.Should().HaveVariable("b").OfType(BuiltinTypeId.Int)
.And.HaveVariable("c").OfType(BuiltinTypeId.Float);
}
}

[TestMethod, Priority(0)]
public async Task BinaryOperators() {
var operators = new[] {
Expand Down
4 changes: 2 additions & 2 deletions src/Analysis/Engine/Test/InheritanceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def virt():
using (var server = await new Server().InitializeAsync(PythonVersions.Required_Python36X)) {
var analysis = await server.OpenDefaultDocumentAndGetAnalysisAsync(code);

analysis.Should().HaveVariable("b").OfType(BuiltinTypeId.Int);
analysis.Should().HaveVariable("b").OfTypes(BuiltinTypeId.Int);
}
}

Expand All @@ -61,7 +61,7 @@ def virt():
using (var server = await new Server().InitializeAsync(PythonVersions.Required_Python36X)) {
var analysis = await server.OpenDefaultDocumentAndGetAnalysisAsync(code);

analysis.Should().HaveVariable("b").OfType(BuiltinTypeId.Int);
analysis.Should().HaveVariable("b").OfTypes(BuiltinTypeId.Int, BuiltinTypeId.Function);
}
}
}
Expand Down