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

make properties with no setter highlighted as readonly in the semantic highlighter #864

Merged
merged 1 commit into from
Nov 11, 2024

Conversation

DetachHead
Copy link
Owner

fixes #529

Copy link
Contributor

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

sympy (https://github.com/sympy/sympy)
-   /tmp/mypy_primer/projects/sympy/sympy/stats/compound_rv.py:107:9 - warning: Return type, "tuple[Unknown, ...] | Unknown | Self@Sum | Self@Expr | Order | Any | Piecewise | Basic | Equality | Relational | Unequality | Sum | 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 | Relational | Unequality | Integral | Literal[0] | None", is partially unknown (reportUnknownParameterType)
-     Type of "compute_expectation" is "(expr: Unknown, rvs: Unknown | None = None, **kwargs: Unknown) -> (tuple[Unknown, ...] | Unknown | Self@Sum | Self@Expr | Order | Any | Piecewise | Basic | Equality | Relational | Unequality | Sum | 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 | Relational | Unequality | Literal[0] | None)" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/sympy/sympy/stats/compound_rv.py:113:20 - warning: Return type, "tuple[Unknown, ...] | Unknown | Self@Sum | Self@Expr | Order | Any | Piecewise | Basic | Equality | Relational | Unequality | Sum | 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 | Relational | Unequality | Literal[0] | None", is partially unknown (reportUnknownVariableType)
-     Type of "doit" is "((**hints: Unknown) -> Equality) | Unknown | ((**hints: Unknown) -> Relational) | ((**hints: Unknown) -> Unequality) | ((**hints: Unknown) -> (tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Order | Any | Piecewise | Basic | Equality | Relational | Unequality | None)) | ((**hints: Unknown) -> Unknown)" (reportUnknownMemberType)
+     Type of "doit" is "((**hints: Unknown) -> Equality) | Unknown | ((**hints: Unknown) -> Relational) | ((**hints: Unknown) -> Unequality) | ((**hints: Unknown) -> (tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Order | Any | Piecewise | Basic | None)) | ((**hints: Unknown) -> Unknown)" (reportUnknownMemberType)
-     Type of "summation" is "(f: Unknown, ...) -> (Equality | Relational | Unequality | Unknown)" (reportUnknownVariableType)
+     Type of "summation" is "(f: Unknown, ...) -> (tuple[Unknown, ...] | Unknown | Self@Sum | Self@Expr | Order | Any | Piecewise | Basic | Equality | Relational | Unequality | None)" (reportUnknownVariableType)
-     Type of "set" is "tuple[tuple[Dummy, _NotImplementedType | LessThan | Unknown | Equality | Relational | Unequality | Any]]" (reportUnknownVariableType)
+     Type of "set" is "tuple[tuple[Dummy, _NotImplementedType | Unknown | Any]]" (reportUnknownVariableType)
-     Type of "density" is "(expr: Unknown, condition: Unknown | None = None, evaluate: bool = True, numsamples: Unknown | None = None, **kwargs: Unknown) -> (dict[Unknown, Unknown] | Density | Unknown | Lambda | Basic | Any | FiniteDensity | None)" (reportUnknownVariableType)
+     Type of "density" is "(expr: Unknown, condition: Unknown | None = None, evaluate: bool = True, numsamples: Unknown | None = None, **kwargs: Unknown) -> Unknown" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/sympy/sympy/stats/drv.py:242:13 - warning: Type of "dens" is partially unknown
+   /tmp/mypy_primer/projects/sympy/sympy/stats/drv.py:242:13 - warning: Type of "dens" is unknown (reportUnknownVariableType)
-     Type of "dens" is "dict[Unknown, Unknown] | Density | Unknown | Lambda | Basic | Any | FiniteDensity | None" (reportUnknownVariableType)
+   /tmp/mypy_primer/projects/sympy/sympy/stats/drv.py:245:53 - warning: Argument type is unknown
+     Argument corresponds to parameter "pdf" in function "__new__" (reportUnknownArgumentType)
-     Type of "doit" is "Unknown | ((**hints: Unknown) -> (tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Order | Any | Piecewise | Basic | Equality | Relational | Unequality | None)) | ((**hints: Unknown) -> Self@Expr) | ((**hints: Unknown) -> Order) | Any | ((**hints: Unknown) -> Piecewise) | ((**hints: Unknown) -> Basic) | ((**hints: Unknown) -> Equality) | ((**hints: Unknown) -> Relational) | ((**hints: Unknown) -> Unequality)" (reportUnknownMemberType)
+     Type of "doit" is "Unknown | ((**hints: Unknown) -> (tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Order | Any | Piecewise | Basic | None)) | ((**hints: Unknown) -> Self@Expr) | ((**hints: Unknown) -> Order) | Any | ((**hints: Unknown) -> Piecewise) | ((**hints: Unknown) -> Basic) | ((**hints: Unknown) -> Equality) | ((**hints: Unknown) -> Relational) | ((**hints: Unknown) -> Unequality)" (reportUnknownMemberType)
-     Type of "probability" is "(condition: Unknown) -> Unknown" (reportUnknownMemberType)
+     Type of "probability" is "(condition: Unknown) -> (Unknown | Probability | Self@Expr | tuple[Unknown, ...] | Sum | Order | Any | Piecewise | Basic | Equality | Relational | Unequality | int)" (reportUnknownMemberType)
-     Type of "doit" is "((**hints: Unknown) -> Equality) | Unknown | ((**hints: Unknown) -> Relational) | ((**hints: Unknown) -> Unequality) | ((**hints: Unknown) -> (tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Order | Any | Piecewise | Basic | Equality | Relational | Unequality | None))" (reportUnknownMemberType)
+     Type of "doit" is "((**hints: Unknown) -> Equality) | Unknown | ((**hints: Unknown) -> Relational) | ((**hints: Unknown) -> Unequality) | ((**hints: Unknown) -> (tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Order | Any | Piecewise | Basic | None))" (reportUnknownMemberType)
-     Type of "doit" is "((**hints: Unknown) -> Equality) | Unknown | ((**hints: Unknown) -> Relational) | ((**hints: Unknown) -> Unequality) | ((**hints: Unknown) -> (tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Order | Any | Piecewise | Basic | Equality | Relational | Unequality | None))" (reportUnknownMemberType)
+     Type of "doit" is "((**hints: Unknown) -> Equality) | Unknown | ((**hints: Unknown) -> Relational) | ((**hints: Unknown) -> Unequality) | ((**hints: Unknown) -> (tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Order | Any | Piecewise | Basic | None))" (reportUnknownMemberType)
-     Type of "set" is "tuple[tuple[Unknown, Unknown | Or]]" (reportUnknownVariableType)
+     Type of "set" is "tuple[tuple[Unknown, Unknown]]" (reportUnknownVariableType)
-     Type of "set" is "tuple[tuple[Unknown, Unknown | Or], ...] | tuple[tuple[Unknown, Unknown | Or] | tuple[Unknown, Unknown], ...]" (reportUnknownVariableType)
+     Type of "set" is "tuple[tuple[Unknown, Unknown], ...]" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/sympy/sympy/stats/frv.py:443:9 - warning: Return type, "tuple[Unknown, ...] | Unknown | Self@Sum | Self@Expr | Order | Any | Piecewise | Basic | Equality | Relational | Unequality | Sum | Literal[0] | None", is partially unknown (reportUnknownParameterType)
+   /tmp/mypy_primer/projects/sympy/sympy/stats/frv.py:443:9 - warning: Return type, "tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Order | Any | Piecewise | Basic | Equality | Relational | Unequality | Literal[0] | None", is partially unknown (reportUnknownParameterType)
-     Type of "doit" is "((**hints: Unknown) -> Equality) | Unknown | ((**hints: Unknown) -> Relational) | ((**hints: Unknown) -> Unequality) | ((**hints: Unknown) -> (tuple[Unknown, ...] | Unknown | Self@Sum | Self@Expr | Order | Any | Piecewise | Basic | Equality | Relational | Unequality | Sum | None))" (reportUnknownMemberType)
+     Type of "doit" is "((**hints: Unknown) -> Equality) | Unknown | ((**hints: Unknown) -> Relational) | ((**hints: Unknown) -> Unequality) | ((**hints: Unknown) -> (tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Order | Any | Piecewise | Basic | None))" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/sympy/sympy/stats/frv.py:451:20 - warning: Return type, "tuple[Unknown, ...] | Unknown | Self@Sum | Self@Expr | Order | Any | Piecewise | Basic | Equality | Relational | Unequality | Sum | None", is partially unknown (reportUnknownVariableType)
+   /tmp/mypy_primer/projects/sympy/sympy/stats/frv.py:451:20 - warning: Return type, "tuple[Unknown, ...] | Unknown | Sum | Self@Expr | Order | Any | Piecewise | Basic | Equality | Relational | Unequality | None", is partially unknown (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/sympy/sympy/stats/frv_types.py:236:9 - warning: Type of "cond" is partially unknown
+   /tmp/mypy_primer/projects/sympy/sympy/stats/frv_types.py:236:9 - warning: Type of "cond" is unknown (reportUnknownVariableType)
-     Type of "cond" is "Unknown | And" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/sympy/sympy/stats/frv_types.py:425:9 - warning: Type of "cond" is partially unknown
+   /tmp/mypy_primer/projects/sympy/sympy/stats/frv_types.py:425:9 - warning: Type of "cond" is unknown (reportUnknownVariableType)
-     Type of "cond" is "Unknown | And" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/sympy/sympy/stats/frv_types.py:814:9 - warning: Type of "cond1" is partially unknown
+   /tmp/mypy_primer/projects/sympy/sympy/stats/frv_types.py:814:9 - warning: Type of "cond1" is unknown (reportUnknownVariableType)
-     Type of "cond1" is "Unknown | And" (reportUnknownVariableType)
-     Type of "summation" is "(f: Unknown, ...) -> (Equality | Relational | Unequality | Unknown)" (reportUnknownVariableType)
+     Type of "summation" is "(f: Unknown, ...) -> (tuple[Unknown, ...] | Unknown | Self@Sum | Self@Expr | Order | Any | Piecewise | Basic | Equality | Relational | Unequality | None)" (reportUnknownVariableType)

... (truncated 483 lines) ...

arviz (https://github.com/arviz-devs/arviz): 4.15x slower (7.7s -> 31.8s in a single noisy sample)

@DetachHead DetachHead merged commit 351dc26 into main Nov 11, 2024
20 checks passed
@DetachHead DetachHead deleted the readonly-property-semantic branch November 11, 2024 14:37
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.

readonly properties should be coloured as readonly
1 participant