diff --git a/src/Analysis/Ast/Impl/Analyzer/Evaluation/ExpressionEval.Operators.cs b/src/Analysis/Ast/Impl/Analyzer/Evaluation/ExpressionEval.Operators.cs
index 80b71ce00..e5dfe0330 100644
--- a/src/Analysis/Ast/Impl/Analyzer/Evaluation/ExpressionEval.Operators.cs
+++ b/src/Analysis/Ast/Impl/Analyzer/Evaluation/ExpressionEval.Operators.cs
@@ -13,15 +13,12 @@
// See the Apache Version 2.0 License for specific language governing
// permissions and limitations under the License.
-using Microsoft.Python.Analysis.Diagnostics;
using Microsoft.Python.Analysis.Modules;
using Microsoft.Python.Analysis.Types;
using Microsoft.Python.Analysis.Types.Collections;
using Microsoft.Python.Analysis.Values;
-using Microsoft.Python.Core;
using Microsoft.Python.Parsing;
using Microsoft.Python.Parsing.Ast;
-using ErrorCodes = Microsoft.Python.Analysis.Diagnostics.ErrorCodes;
namespace Microsoft.Python.Analysis.Analyzer.Evaluation {
internal sealed partial class ExpressionEval {
@@ -124,9 +121,6 @@ private IMember GetValueFromBinaryOp(Expression expr) {
if (leftIsSupported && rightIsSupported) {
if (TryGetValueFromBuiltinBinaryOp(op, leftTypeId, rightTypeId, Interpreter.LanguageVersion.Is3x(), out var member)) {
- if (member.IsUnknown()) {
- ReportOperatorDiagnostics(expr, leftType, rightType, op);
- }
return member;
}
}
@@ -440,14 +434,5 @@ private static (string name, string swappedName) OpMethodName(PythonOperator op)
return (null, null);
}
- private void ReportOperatorDiagnostics(Expression expr, IPythonType leftType, IPythonType rightType, PythonOperator op) {
- ReportDiagnostics(Module.Uri, new DiagnosticsEntry(
- Resources.UnsupporedOperandType.FormatInvariant(op.ToCodeString(), leftType.Name, rightType.Name),
- GetLocation(expr).Span,
- ErrorCodes.UnsupportedOperandType,
- Severity.Error,
- DiagnosticSource.Analysis));
- }
-
}
}
diff --git a/src/Analysis/Ast/Impl/Diagnostics/ErrorCodes.cs b/src/Analysis/Ast/Impl/Diagnostics/ErrorCodes.cs
index 38ca89d3e..7a5f419c2 100644
--- a/src/Analysis/Ast/Impl/Diagnostics/ErrorCodes.cs
+++ b/src/Analysis/Ast/Impl/Diagnostics/ErrorCodes.cs
@@ -25,7 +25,6 @@ public static class ErrorCodes {
public const string UndefinedVariable = "undefined-variable";
public const string VariableNotDefinedGlobally= "variable-not-defined-globally";
public const string VariableNotDefinedNonLocal = "variable-not-defined-nonlocal";
- public const string UnsupportedOperandType = "unsupported-operand-type";
public const string ReturnInInit = "return-in-init";
public const string TypingNewTypeArguments = "typing-newtype-arguments";
public const string TypingGenericArguments = "typing-generic-arguments";
diff --git a/src/Analysis/Ast/Impl/Resources.Designer.cs b/src/Analysis/Ast/Impl/Resources.Designer.cs
index 8f9f7d5e9..511ddd1b9 100644
--- a/src/Analysis/Ast/Impl/Resources.Designer.cs
+++ b/src/Analysis/Ast/Impl/Resources.Designer.cs
@@ -320,14 +320,5 @@ internal static string UndefinedVariable {
return ResourceManager.GetString("UndefinedVariable", resourceCulture);
}
}
-
- ///
- /// Looks up a localized string similar to Unsupported operand types for '{0}': '{1}' and '{2}'.
- ///
- internal static string UnsupporedOperandType {
- get {
- return ResourceManager.GetString("UnsupporedOperandType", resourceCulture);
- }
- }
}
}
diff --git a/src/Analysis/Ast/Impl/Resources.resx b/src/Analysis/Ast/Impl/Resources.resx
index da773f355..b939ac1c8 100644
--- a/src/Analysis/Ast/Impl/Resources.resx
+++ b/src/Analysis/Ast/Impl/Resources.resx
@@ -192,9 +192,6 @@
The first argument to NewType must be a string, but it is of type '{0}'.
-
- Unsupported operand types for '{0}': '{1}' and '{2}'
-
Explicit return in __init__
diff --git a/src/Analysis/Ast/Test/LintNoQATests.cs b/src/Analysis/Ast/Test/LintNoQATests.cs
index 92c1bf924..9de8a4d18 100644
--- a/src/Analysis/Ast/Test/LintNoQATests.cs
+++ b/src/Analysis/Ast/Test/LintNoQATests.cs
@@ -81,16 +81,15 @@ public async Task IgnoreNoQAUppercase(string code) {
[TestMethod, Priority(0)]
public async Task VarNamedNoQAStillGivesDiagnostic() {
- const string code = @"
-noqa = 1 + 'str'
-";
+ string code = GenericSetup + "NOQA = Generic[T, T]";
+
var analysis = await GetAnalysisAsync(code);
analysis.Diagnostics.Should().HaveCount(1);
var diagnostic = analysis.Diagnostics.ElementAt(0);
- diagnostic.ErrorCode.Should().Be(ErrorCodes.UnsupportedOperandType);
- diagnostic.Message.Should().Be(Resources.UnsupporedOperandType.FormatInvariant("+", "int", "str"));
- diagnostic.SourceSpan.Should().Be(2, 8, 2, 17);
+ diagnostic.Message.Should().Be(Resources.GenericNotAllUnique);
+ diagnostic.ErrorCode.Should().Be(ErrorCodes.TypingGenericArguments);
+ diagnostic.SourceSpan.Should().Be(8, 8, 8, 21);
diagnostic.Severity.Should().Be(Severity.Error);
}
diff --git a/src/Analysis/Ast/Test/LintOperatorTests.cs b/src/Analysis/Ast/Test/LintOperatorTests.cs
deleted file mode 100644
index 0578dbdbd..000000000
--- a/src/Analysis/Ast/Test/LintOperatorTests.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-using System.Linq;
-using System.Threading.Tasks;
-using FluentAssertions;
-using Microsoft.Python.Analysis.Tests.FluentAssertions;
-using Microsoft.Python.Core;
-using Microsoft.Python.Parsing.Tests;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using TestUtilities;
-
-namespace Microsoft.Python.Analysis.Tests {
- [TestClass]
- public class LintOperatorTests : AnalysisTestBase {
-
- public TestContext TestContext { get; set; }
-
- [TestInitialize]
- public void TestInitialize()
- => TestEnvironmentImpl.TestInitialize($"{TestContext.FullyQualifiedTestClassName}.{TestContext.TestName}");
-
- [TestCleanup]
- public void Cleanup() => TestEnvironmentImpl.TestCleanup();
-
- [TestMethod, Priority(0)]
- public async Task IncompatibleTypesBinaryOpBasic() {
- var code = $@"
-a = 5 + 'str'
-";
-
- var analysis = await GetAnalysisAsync(code, PythonVersions.LatestAvailable3X);
- analysis.Diagnostics.Should().HaveCount(1);
-
- var diagnostic = analysis.Diagnostics.ElementAt(0);
- diagnostic.SourceSpan.Should().Be(2, 5, 2, 14);
- diagnostic.ErrorCode.Should().Be(Diagnostics.ErrorCodes.UnsupportedOperandType);
- diagnostic.Message.Should().Be(Resources.UnsupporedOperandType.FormatInvariant("+", "int", "str"));
- }
-
- [DataRow("str", "int", "+")]
- [DataRow("str", "int", "-")]
- [DataRow("str", "int", "/")]
- [DataRow("str", "float", "+")]
- [DataRow("str", "float", "-")]
- [DataRow("str", "float", "*")]
- [DataTestMethod, Priority(0)]
- public async Task IncompatibleTypesBinaryOp(string leftType, string rightType, string op) {
- var code = $@"
-x = 1
-y = 2
-
-z = {leftType}(x) {op} {rightType}(y)
-";
-
- var analysis = await GetAnalysisAsync(code, PythonVersions.LatestAvailable3X);
- analysis.Diagnostics.Should().HaveCount(1);
-
- var diagnostic = analysis.Diagnostics.ElementAt(0);
-
-
- string line = $"z = {leftType}(x) {op} {rightType}(y)";
- // source span is 1 indexed
- diagnostic.SourceSpan.Should().Be(5, line.IndexOf(leftType) + 1, 5, line.IndexOf("(y)") + 4);
- diagnostic.ErrorCode.Should().Be(Diagnostics.ErrorCodes.UnsupportedOperandType);
- diagnostic.Message.Should().Be(Resources.UnsupporedOperandType.FormatInvariant(op, leftType, rightType));
- }
-
- [DataRow("str", "str", "+")]
- [DataRow("int", "int", "-")]
- [DataRow("bool", "int", "/")]
- [DataRow("float", "int", "+")]
- [DataRow("complex", "float", "-")]
- [DataRow("str", "int", "*")]
- [DataTestMethod, Priority(0)]
- public async Task CompatibleTypesBinaryOp(string leftType, string rightType, string op) {
- var code = $@"
-x = 1
-y = 2
-
-z = {leftType}(x) {op} {rightType}(y)
-";
-
- var analysis = await GetAnalysisAsync(code, PythonVersions.LatestAvailable3X);
- analysis.Diagnostics.Should().BeEmpty();
- }
- }
-
-}