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 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
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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));
}

}
}
1 change: 0 additions & 1 deletion src/Analysis/Ast/Impl/Diagnostics/ErrorCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
9 changes: 0 additions & 9 deletions src/Analysis/Ast/Impl/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions src/Analysis/Ast/Impl/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,6 @@
<data name="NewTypeFirstArgNotString" xml:space="preserve">
<value>The first argument to NewType must be a string, but it is of type '{0}'.</value>
</data>
<data name="UnsupporedOperandType" xml:space="preserve">
<value>Unsupported operand types for '{0}': '{1}' and '{2}'</value>
</data>
<data name="ReturnInInit" xml:space="preserve">
<value>Explicit return in __init__ </value>
</data>
Expand Down
11 changes: 5 additions & 6 deletions src/Analysis/Ast/Test/LintNoQATests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
86 changes: 0 additions & 86 deletions src/Analysis/Ast/Test/LintOperatorTests.cs

This file was deleted.