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

fix semantic highlighting on names that are wrapped in parentheses across multiple lines #957

Merged
merged 2 commits into from
Dec 17, 2024

Conversation

DetachHead
Copy link
Owner

fixes #353

Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

sympy (https://github.com/sympy/sympy)
-     Type of "n" is "Unknown | ((n: int = 15, subs: dict[Basic, Basic | float] | None = None, maxn: int = 100, chop: bool = False, strict: bool = False, quad: str | None = None, verbose: bool = False) -> Expr)" (reportUnknownMemberType)
+     Type of "n" is "Unknown | ((n: int = 15, subs: dict[Basic, Basic | float] | None = None, maxn: int = 100, chop: bool = False, strict: bool = False, quad: str | None = None, verbose: bool = False) -> Expr) | Any" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_solveset.py:506:20 - warning: Argument type is unknown
-     Argument corresponds to parameter "args" in function "__new__" (reportUnknownArgumentType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_solveset.py:706:26 - warning: Argument type is Any
+     Argument corresponds to parameter "f" in function "solveset_real" (reportAny)
-     Type of "expr1" is "Equality | Unknown | Relational | Unequality" (reportUnknownVariableType)
+     Type of "expr1" is "Equality | Unknown" (reportUnknownVariableType)
-     Type of "expr2" is "Equality | Unknown | Relational | Unequality" (reportUnknownVariableType)
+     Type of "expr2" is "Equality | Unknown" (reportUnknownVariableType)
-     Type of "eqns2" is "list[Equality | Unknown | Relational | Unequality | Any]" (reportUnknownVariableType)
+     Type of "eqns2" is "list[Equality | Unknown | Any]" (reportUnknownVariableType)
-     Type of "number" is "Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Expr" (reportUnknownVariableType)
+     Type of "number" is "Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | _NotImplementedType | Expr" (reportUnknownVariableType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_solveset.py:2793:21 - warning: Argument type is Any
+     Argument corresponds to parameter "f" in function "solveset" (reportAny)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_solveset.py:3411:13 - warning: Argument type is Any
+     Argument corresponds to parameter "lhs" in function "__new__" (reportAny)
-     Type of "eq1" is "list[Equality | Unknown | Relational | Unequality]" (reportUnknownVariableType)
+     Type of "eq1" is "list[Equality | Unknown]" (reportUnknownVariableType)
-     Type of "eq2" is "list[Equality | Unknown | Relational | Unequality]" (reportUnknownVariableType)
+     Type of "eq2" is "list[Equality | Unknown]" (reportUnknownVariableType)
-     Type of "eqs_eq" is "list[Equality | Unknown | Relational | Unequality]" (reportUnknownVariableType)
+     Type of "eqs_eq" is "list[Equality | Unknown]" (reportUnknownVariableType)
-     Type of "eq" is "Equality | Unknown | Relational | Unequality" (reportUnknownVariableType)
+     Type of "eq" is "Equality | Unknown" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_solveset.py:3513:5 - warning: Type of "e" is partially unknown
-     Type of "e" is "ComplexInfinity | Rational | NaN | One | NegativeOne | Zero | Integer | Half | Unknown" (reportUnknownVariableType)
-     Type of "ans" is "set[tuple[Any | Unknown, Any] | tuple[Unknown, Any]]" (reportUnknownVariableType)
+     Type of "ans" is "set[tuple[Any, Any] | tuple[Unknown, Any]]" (reportUnknownVariableType)
-     Type of "P" is "(condition: Unknown, given_condition: Unknown | None = None, numsamples: Unknown | None = None, evaluate: bool = True, **kwargs: Unknown) -> (Unknown | Any | BernoulliDistribution | Probability | Zero | One | Self@Expr | tuple[Unknown, ...] | Sum | Expr | NaN | Piecewise | Basic | Equality | Relational | Unequality | ComplexInfinity | Float | Half | Infinity | Integer | Lambda | NegativeInfinity | NegativeOne | Number | Rational | int | None)" (reportUnknownVariableType)
+     Type of "P" is "(condition: Unknown, given_condition: Unknown | None = None, numsamples: Unknown | None = None, evaluate: bool = True, **kwargs: Unknown) -> (Unknown | Any | BernoulliDistribution | Probability | Zero | One | Expr | Float | ComplexInfinity | Rational | NaN | NegativeOne | Integer | Half | Infinity | NegativeInfinity | _NotImplementedType | Self@Expr | tuple[Unknown, ...] | Sum | Piecewise | Basic | Equality | Lambda | Number | int | None)" (reportUnknownVariableType)
-     Type of "E" is "(expr: Unknown, condition: Unknown | None = None, numsamples: Unknown | None = None, evaluate: bool = True, **kwargs: Unknown) -> (Unknown | Basic | Expectation | Expr | tuple[Unknown, ...] | Sum | Self@Expr | Any | Zero | NaN | Piecewise | Equality | Relational | Unequality | Integral | ExpectationMatrix | Literal[0] | None)" (reportUnknownVariableType)
+     Type of "E" is "(expr: Unknown, condition: Unknown | None = None, numsamples: Unknown | None = None, evaluate: bool = True, **kwargs: Unknown) -> (Unknown | Basic | Expectation | Expr | tuple[Unknown, ...] | Sum | Self@Expr | Any | Zero | NaN | Piecewise | Equality | Integral | ExpectationMatrix | Literal[0] | None)" (reportUnknownVariableType)
-     Type of "H" is "(expr: Unknown, condition: Unknown | None = None, **kwargs: Unknown) -> (int | Expr | Basic | Expectation | tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Any | Zero | NaN | Piecewise | Equality | Relational | Unequality | Integral | ExpectationMatrix | None)" (reportUnknownVariableType)
+     Type of "H" is "(expr: Unknown, condition: Unknown | None = None, **kwargs: Unknown) -> (int | Expr | Basic | Expectation | tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Any | Zero | NaN | Piecewise | Equality | Integral | ExpectationMatrix | None)" (reportUnknownVariableType)
-     Type of "covariance" is "(X: Unknown, Y: Unknown, condition: Unknown | None = None, **kwargs: Unknown) -> (CrossCovarianceMatrix | Covariance | Unknown | Basic | Expectation | Expr | tuple[Unknown, ...] | Sum | Self@Expr | Any | Zero | NaN | Piecewise | Equality | Relational | Unequality | Integral | ExpectationMatrix | Literal[0] | None)" (reportUnknownVariableType)
+     Type of "covariance" is "(X: Unknown, Y: Unknown, condition: Unknown | None = None, **kwargs: Unknown) -> (CrossCovarianceMatrix | Covariance | Unknown | Basic | Expectation | Expr | tuple[Unknown, ...] | Sum | Self@Expr | Any | Zero | NaN | Piecewise | Equality | Integral | ExpectationMatrix | Literal[0] | None)" (reportUnknownVariableType)
-     Type of "entropy" is "(expr: Unknown, condition: Unknown | None = None, **kwargs: Unknown) -> (int | Expr | Basic | Expectation | tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Any | Zero | NaN | Piecewise | Equality | Relational | Unequality | Integral | ExpectationMatrix | None)" (reportUnknownVariableType)
+     Type of "entropy" is "(expr: Unknown, condition: Unknown | None = None, **kwargs: Unknown) -> (int | Expr | Basic | Expectation | tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Any | Zero | NaN | Piecewise | Equality | Integral | ExpectationMatrix | None)" (reportUnknownVariableType)
-     Type of "correlation" is "(X: Unknown, Y: Unknown, condition: Unknown | None = None, **kwargs: Unknown) -> (Unknown | Expr | Any | ComplexInfinity | Rational | NaN | One | NegativeOne | Zero | Integer | Half)" (reportUnknownVariableType)
+     Type of "correlation" is "(X: Unknown, Y: Unknown, condition: Unknown | None = None, **kwargs: Unknown) -> (Unknown | Expr | Any | ComplexInfinity | Rational | NaN | One | NegativeOne | Zero | Integer | Half | Infinity | NegativeInfinity | Float | _NotImplementedType)" (reportUnknownVariableType)
-     Type of "factorial_moment" is "(X: Unknown, n: Unknown, condition: Unknown | None = None, **kwargs: Unknown) -> (Expr | Basic | Expectation | tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Any | Zero | NaN | Piecewise | Equality | Relational | Unequality | Integral | ExpectationMatrix | Literal[0] | None)" (reportUnknownVariableType)
+     Type of "factorial_moment" is "(X: Unknown, n: Unknown, condition: Unknown | None = None, **kwargs: Unknown) -> (Expr | Basic | Expectation | tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Any | Zero | NaN | Piecewise | Equality | Integral | ExpectationMatrix | Literal[0] | None)" (reportUnknownVariableType)
-     Type of "coskewness" is "(X: Unknown, Y: Unknown, Z: Unknown, condition: Unknown | None = None, **kwargs: Unknown) -> (Unknown | Expr | Any | ComplexInfinity | Rational | NaN | One | NegativeOne | Zero | Integer | Half)" (reportUnknownVariableType)
+     Type of "coskewness" is "(X: Unknown, Y: Unknown, Z: Unknown, condition: Unknown | None = None, **kwargs: Unknown) -> (Unknown | Expr | Any | ComplexInfinity | Rational | NaN | One | NegativeOne | Zero | Integer | Half | Infinity | NegativeInfinity | Float | _NotImplementedType)" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/sympy/sympy/stats/compound_rv.py:107:9 - warning: Return type, "tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Expr | Any | Zero | NaN | Piecewise | Basic | Equality | Relational | Unequality | Integral | Literal[0] | None", is partially unknown (reportUnknownParameterType)
+   /tmp/mypy_primer/projects/sympy/sympy/stats/compound_rv.py:107:9 - warning: Return type, "tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Expr | Any | Zero | NaN | Piecewise | Basic | Equality | Integral | Literal[0] | None", is partially unknown (reportUnknownParameterType)
-     Type of "compute_expectation" is "(expr: Unknown, rvs: Unknown | None = None, **kwargs: Unknown) -> (tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Expr | Any | Zero | NaN | Piecewise | Basic | Equality | Relational | Unequality | Literal[0] | None)" (reportUnknownMemberType)
+     Type of "compute_expectation" is "(expr: Unknown, rvs: Unknown | None = None, **kwargs: Unknown) -> (tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Expr | Any | Zero | NaN | Piecewise | Basic | Equality | Literal[0] | None)" (reportUnknownMemberType)

... (truncated 4073 lines) ...

arviz (https://github.com/arviz-devs/arviz): 3.83x slower (8.2s -> 31.6s in a single noisy sample)

@DetachHead DetachHead merged commit aa93f18 into main Dec 17, 2024
20 checks passed
@DetachHead DetachHead deleted the fix-semantic-highlighting branch December 17, 2024 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

variables are coloured white if they are wrapped in parentheses across multiple lines
1 participant