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 unknown imports being incorrectly highlighted as a variable #863

Merged
merged 2 commits into from
Nov 11, 2024

Conversation

DetachHead
Copy link
Owner

fixes #414

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 "P" is "(condition: Unknown, given_condition: Unknown | None = None, numsamples: Unknown | None = None, evaluate: bool = True, **kwargs: Unknown) -> (Unknown | Any | BernoulliDistribution | Probability | Self@Expr | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Lambda | Relational | Unequality | 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 | Self@Expr | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Lambda | 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 | tuple[Unknown, ...] | Sum | Self@Expr | Order | Any | 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 | tuple[Unknown, ...] | Sum | Self@Expr | Order | Any | Piecewise | Equality | Integral | ExpectationMatrix | Literal[0] | None)" (reportUnknownVariableType)
-     Type of "H" is "(expr: Unknown, condition: Unknown | None = None, **kwargs: Unknown) -> (int | Expr | Basic | Expectation | Unknown | tuple[Unknown, ...] | Sum | Self@Expr | Order | Any | Piecewise | Equality | Relational | Unequality | Integral | ExpectationMatrix | None)" (reportUnknownVariableType)
+     Type of "H" is "(expr: Unknown, condition: Unknown | None = None, **kwargs: Unknown) -> (int | Expr | Basic | Expectation | Unknown | tuple[Unknown, ...] | Sum | Self@Expr | Order | Any | 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 | tuple[Unknown, ...] | Sum | Self@Expr | Order | Any | 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 | tuple[Unknown, ...] | Sum | Self@Expr | Order | Any | Piecewise | Equality | Integral | ExpectationMatrix | Literal[0] | None)" (reportUnknownVariableType)
-     Type of "entropy" is "(expr: Unknown, condition: Unknown | None = None, **kwargs: Unknown) -> (int | Expr | Basic | Expectation | Unknown | tuple[Unknown, ...] | Sum | Self@Expr | Order | Any | Piecewise | Equality | Relational | Unequality | Integral | ExpectationMatrix | None)" (reportUnknownVariableType)
+     Type of "entropy" is "(expr: Unknown, condition: Unknown | None = None, **kwargs: Unknown) -> (int | Expr | Basic | Expectation | Unknown | tuple[Unknown, ...] | Sum | Self@Expr | Order | Any | Piecewise | Equality | Integral | ExpectationMatrix | None)" (reportUnknownVariableType)
-     Type of "factorial_moment" is "(X: Unknown, n: Unknown, condition: Unknown | None = None, **kwargs: Unknown) -> (Expr | Basic | Expectation | Unknown | tuple[Unknown, ...] | Sum | Self@Expr | Order | Any | 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 | Unknown | tuple[Unknown, ...] | Sum | Self@Expr | Order | Any | Piecewise | Equality | Integral | ExpectationMatrix | Literal[0] | None)" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/sympy/sympy/stats/compound_rv.py:107:9 - warning: Return type, "tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Order | Any | 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 | Order | Any | 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 | Order | Any | 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 | Order | Any | Piecewise | Basic | Equality | Literal[0] | None)" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/sympy/sympy/stats/compound_rv.py:113:20 - warning: Return type, "tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Order | Any | Piecewise | Basic | Equality | Relational | Unequality | Literal[0] | None", is partially unknown (reportUnknownVariableType)
+   /tmp/mypy_primer/projects/sympy/sympy/stats/compound_rv.py:113:20 - warning: Return type, "tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Order | Any | Piecewise | Basic | Equality | Literal[0] | None", is partially unknown (reportUnknownVariableType)
-     Type of "compute_expectation" is "((expr: Unknown, rvs: Unknown | None = None, evaluate: bool = False, **kwargs: Unknown) -> (Unknown | Equality | Relational | Unequality | Integral)) | ((expr: Unknown, rvs: Unknown | None = None, evaluate: bool = True, **kwargs: Unknown) -> (Unknown | Equality | Relational | Unequality | Sum))" (reportUnknownMemberType)
+     Type of "compute_expectation" is "((expr: Unknown, rvs: Unknown | None = None, evaluate: bool = False, **kwargs: Unknown) -> (Unknown | Equality | Integral)) | ((expr: Unknown, rvs: Unknown | None = None, evaluate: bool = True, **kwargs: Unknown) -> (Unknown | Equality | Sum))" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/sympy/sympy/stats/compound_rv.py:114:16 - warning: Return type, "Unknown | Equality | Relational | Unequality | Integral | Sum", is partially unknown (reportUnknownVariableType)
+   /tmp/mypy_primer/projects/sympy/sympy/stats/compound_rv.py:114:16 - warning: Return type, "Unknown | Equality | Integral | Sum", is partially unknown (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/sympy/sympy/stats/compound_rv.py:116:9 - warning: Return type, "Unknown | Probability | Self@Expr | tuple[Unknown, ...] | Sum | Order | Any | Piecewise | Basic | Equality | Relational | Unequality | int", is partially unknown (reportUnknownParameterType)
+   /tmp/mypy_primer/projects/sympy/sympy/stats/compound_rv.py:116:9 - warning: Return type, "Unknown | Probability | Self@Expr | tuple[Unknown, ...] | Sum | Order | Any | Piecewise | Basic | Equality | int", is partially unknown (reportUnknownParameterType)
-     Type of "probability" is "((condition: Unknown, **kwargs: Unknown) -> Unknown) | ((condition: Unknown) -> (Unknown | Probability | Self@Expr | tuple[Unknown, ...] | Sum | Order | Any | Piecewise | Basic | Equality | Relational | Unequality | int)) | ((condition: Unknown) -> (Unknown | Piecewise | Literal[0]))" (reportUnknownMemberType)
+     Type of "probability" is "((condition: Unknown, **kwargs: Unknown) -> Unknown) | ((condition: Unknown) -> (Unknown | Probability | Self@Expr | tuple[Unknown, ...] | Sum | Order | Any | Piecewise | Basic | Equality | int)) | ((condition: Unknown) -> (Unknown | Piecewise | Literal[0]))" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/sympy/sympy/stats/compound_rv.py:119:16 - warning: Return type, "Unknown | Probability | Self@Expr | tuple[Unknown, ...] | Sum | Order | Any | Piecewise | Basic | Equality | Relational | Unequality | int", is partially unknown (reportUnknownVariableType)
+   /tmp/mypy_primer/projects/sympy/sympy/stats/compound_rv.py:119:16 - warning: Return type, "Unknown | Probability | Self@Expr | tuple[Unknown, ...] | Sum | Order | Any | Piecewise | Basic | Equality | int", is partially unknown (reportUnknownVariableType)
-     Type of "expr" is "tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Order | Any | Piecewise | Basic | Equality | Relational | Unequality | Integral | None" (reportUnknownVariableType)
+     Type of "expr" is "tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Order | Any | Piecewise | Basic | Equality | Integral | None" (reportUnknownVariableType)
-     Type of "_marginalise" is "(expr: Unknown, rv: Unknown, evaluate: Unknown) -> (tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Order | Any | Piecewise | Basic | Equality | Relational | Unequality | Integral | None)" (reportUnknownMemberType)
+     Type of "_marginalise" is "(expr: Unknown, rv: Unknown, evaluate: Unknown) -> (tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Order | Any | Piecewise | Basic | Equality | Integral | None)" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/sympy/sympy/stats/compound_rv.py:197:9 - warning: Return type, "tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Order | Any | Piecewise | Basic | Equality | Relational | Unequality | Integral | None", is partially unknown (reportUnknownParameterType)
+   /tmp/mypy_primer/projects/sympy/sympy/stats/compound_rv.py:197:9 - warning: Return type, "tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Order | Any | Piecewise | Basic | Equality | Integral | None", is partially unknown (reportUnknownParameterType)
-     Type of "expr" is "Equality | Unknown | Relational | Unequality | Sum" (reportUnknownVariableType)

... (truncated 715 lines) ...

@DetachHead DetachHead merged commit 91d273b into main Nov 11, 2024
20 checks passed
@DetachHead DetachHead deleted the fix-unknown-import-semantic-highlighting branch November 11, 2024 10:43
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.

unknown imports should be coloured white
1 participant