-
Notifications
You must be signed in to change notification settings - Fork 32
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
Change default to use ".venv" under project root #1001
Conversation
fixes DetachHead#365 If project root is found, and ".venv" is found under project root, use that venv as default. Project root is found if "pyrightconfig.json" or "pyproject.toml" is found. ".venv" can change to another name by change the '[tool.pyright] venv="venv_name"' in "pyproject.toml". But note that `uv` only support ".venv" so better stick with that.
thanks for the contribution. i think this sounds like a good idea, however i want to hold off merging it until #570 is resolved because otherwise there'll be no workaround |
Diff from mypy_primer, showing the effect of this PR on open source code: sympy (https://github.com/sympy/sympy)
- Type of "sol1" is "Equality | Unknown | Relational | Unequality | Integer" (reportUnknownVariableType)
+ Type of "sol1" is "Equality | Unknown" (reportUnknownVariableType)
- /tmp/mypy_primer/projects/sympy/sympy/solvers/ode/tests/test_subscheck.py:37:34 - error: Cannot access attribute "lhs" for class "Integer"
- Attribute "lhs" is unknown (reportAttributeAccessIssue)
- /tmp/mypy_primer/projects/sympy/sympy/solvers/ode/tests/test_subscheck.py:38:34 - error: Cannot access attribute "lhs" for class "Integer"
- Attribute "lhs" is unknown (reportAttributeAccessIssue)
- /tmp/mypy_primer/projects/sympy/sympy/solvers/ode/tests/test_subscheck.py:39:34 - error: Cannot access attribute "lhs" for class "Integer"
- Attribute "lhs" is unknown (reportAttributeAccessIssue)
- /tmp/mypy_primer/projects/sympy/sympy/solvers/ode/tests/test_subscheck.py:40:34 - error: Cannot access attribute "lhs" for class "Integer"
- Attribute "lhs" is unknown (reportAttributeAccessIssue)
- /tmp/mypy_primer/projects/sympy/sympy/solvers/ode/tests/test_subscheck.py:41:34 - error: Cannot access attribute "lhs" for class "Integer"
- Attribute "lhs" is unknown (reportAttributeAccessIssue)
- /tmp/mypy_primer/projects/sympy/sympy/solvers/ode/tests/test_subscheck.py:42:34 - error: Cannot access attribute "lhs" for class "Integer"
- Attribute "lhs" is unknown (reportAttributeAccessIssue)
- /tmp/mypy_primer/projects/sympy/sympy/solvers/ode/tests/test_subscheck.py:43:34 - error: Cannot access attribute "lhs" for class "Integer"
- Attribute "lhs" is unknown (reportAttributeAccessIssue)
- Type of "sol3" is "Equality | Unknown | Relational | Unequality | Integer" (reportUnknownVariableType)
+ Type of "sol3" is "Equality | Unknown" (reportUnknownVariableType)
- Type of "eqn" is "Equality | Unknown | Relational | Unequality | Integer" (reportUnknownVariableType)
+ Type of "eqn" is "Equality | Unknown" (reportUnknownVariableType)
- Type of "sol" is "Equality | Unknown | Relational | Unequality | Integer" (reportUnknownVariableType)
+ Type of "sol" is "Equality | Unknown" (reportUnknownVariableType)
- Type of "sol" is "Equality | Unknown | Relational | Unequality | Integer" (reportUnknownVariableType)
+ Type of "sol" is "Equality | Unknown" (reportUnknownVariableType)
- Type of "eqs" is "list[Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "eqs" is "list[Equality | Unknown]" (reportUnknownVariableType)
- Type of "sol" is "list[Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "sol" is "list[Equality | Unknown]" (reportUnknownVariableType)
- Type of "eq" is "tuple[Equality | Unknown | Relational | Unequality | Integer, Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "eq" is "tuple[Equality | Unknown, Equality | Unknown]" (reportUnknownVariableType)
- Type of "sol" is "list[Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "sol" is "list[Equality | Unknown]" (reportUnknownVariableType)
- Type of "eq" is "tuple[Equality | Unknown | Relational | Unequality | Integer, Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "eq" is "tuple[Equality | Unknown, Equality | Unknown]" (reportUnknownVariableType)
- Type of "sol" is "list[Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "sol" is "list[Equality | Unknown]" (reportUnknownVariableType)
- Type of "eq" is "tuple[Equality | Unknown | Relational | Unequality | Integer, Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "eq" is "tuple[Equality | Unknown, Equality | Unknown]" (reportUnknownVariableType)
- Type of "sol" is "list[Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "sol" is "list[Equality | Unknown]" (reportUnknownVariableType)
- Type of "eq" is "tuple[Equality | Unknown | Relational | Unequality | Integer, Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "eq" is "tuple[Equality | Unknown, Equality | Unknown]" (reportUnknownVariableType)
- Type of "sol" is "list[Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "sol" is "list[Equality | Unknown]" (reportUnknownVariableType)
- Type of "eq" is "tuple[Equality | Unknown | Relational | Unequality | Integer, Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "eq" is "tuple[Equality | Unknown, Equality | Unknown]" (reportUnknownVariableType)
- Type of "sol" is "list[Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "sol" is "list[Equality | Unknown]" (reportUnknownVariableType)
- Type of "eq" is "tuple[Equality | Unknown | Relational | Unequality | Integer, Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "eq" is "tuple[Equality | Unknown, Equality | Unknown]" (reportUnknownVariableType)
- Type of "sol" is "list[Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "sol" is "list[Equality | Unknown]" (reportUnknownVariableType)
- Type of "eq" is "tuple[Equality | Unknown | Relational | Unequality | Integer, Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "eq" is "tuple[Equality | Unknown, Equality | Unknown]" (reportUnknownVariableType)
- Type of "sol" is "list[Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "sol" is "list[Equality | Unknown]" (reportUnknownVariableType)
- Type of "eq" is "tuple[Equality | Unknown | Relational | Unequality | Integer, Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "eq" is "tuple[Equality | Unknown, Equality | Unknown]" (reportUnknownVariableType)
- Type of "sol" is "list[Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "sol" is "list[Equality | Unknown]" (reportUnknownVariableType)
- Type of "eq" is "tuple[Equality | Unknown | Relational | Unequality | Integer, Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "eq" is "tuple[Equality | Unknown, Equality | Unknown]" (reportUnknownVariableType)
- Type of "sol" is "list[Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "sol" is "list[Equality | Unknown]" (reportUnknownVariableType)
- Type of "eq" is "tuple[Equality | Unknown | Relational | Unequality | Integer, Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "eq" is "tuple[Equality | Unknown, Equality | Unknown]" (reportUnknownVariableType)
- Type of "sol" is "list[Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "sol" is "list[Equality | Unknown]" (reportUnknownVariableType)
- Type of "eq" is "tuple[Equality | Unknown | Relational | Unequality | Integer, Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "eq" is "tuple[Equality | Unknown, Equality | Unknown]" (reportUnknownVariableType)
- Type of "sol" is "list[Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "sol" is "list[Equality | Unknown]" (reportUnknownVariableType)
- Type of "eq" is "tuple[Equality | Unknown | Relational | Unequality | Integer, Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "eq" is "tuple[Equality | Unknown, Equality | Unknown]" (reportUnknownVariableType)
- Type of "sol" is "list[Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "sol" is "list[Equality | Unknown]" (reportUnknownVariableType)
- Type of "eq" is "tuple[Equality | Unknown | Relational | Unequality | Integer, Equality | Unknown | Relational | Unequality | Integer, Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "eq" is "tuple[Equality | Unknown, Equality | Unknown, Equality | Unknown]" (reportUnknownVariableType)
- Type of "sol" is "list[Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "sol" is "list[Equality | Unknown]" (reportUnknownVariableType)
- Type of "eq" is "tuple[Equality | Unknown | Relational | Unequality | Integer, Equality | Unknown | Relational | Unequality | Integer, Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "eq" is "tuple[Equality | Unknown, Equality | Unknown, Equality | Unknown]" (reportUnknownVariableType)
- Type of "sol" is "list[Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "sol" is "list[Equality | Unknown]" (reportUnknownVariableType)
- Type of "eq" is "tuple[Equality | Unknown | Relational | Unequality | Integer, Equality | Unknown | Relational | Unequality | Integer, Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "eq" is "tuple[Equality | Unknown, Equality | Unknown, Equality | Unknown]" (reportUnknownVariableType)
- Type of "sol" is "list[Equality | Unknown | Relational | Unequality | Integer]" (reportUnknownVariableType)
+ Type of "sol" is "list[Equality | Unknown]" (reportUnknownVariableType)
... (truncated 3441 lines) ...
black (https://github.com/psf/black): 5.96x slower (2.2s -> 12.8s in a single noisy sample)
spack (https://github.com/spack/spack)
- /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/dtlink3/package.py:16:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
- /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/dtlink3/package.py:17:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+ /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/dtlink3/package.py:16:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+ /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/dtlink3/package.py:17:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
- /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/dtrun1/package.py:16:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
- /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/dtrun1/package.py:17:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+ /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/dtrun1/package.py:16:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+ /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/dtrun1/package.py:17:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
- /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/dtrun3/package.py:16:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+ /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/dtrun3/package.py:16:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
- /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/dttop/package.py:16:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
- /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/dttop/package.py:17:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
- /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/dttop/package.py:18:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+ /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/dttop/package.py:16:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+ /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/dttop/package.py:17:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+ /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/dttop/package.py:18:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
- /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/dtuse/package.py:16:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+ /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/dtuse/package.py:16:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
- /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/dyninst/package.py:28:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
- /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/dyninst/package.py:29:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+ /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/dyninst/package.py:28:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+ /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/dyninst/package.py:29:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
- /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/ecp-viz-sdk/package.py:17:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+ /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/ecp-viz-sdk/package.py:17:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
- /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/extension2/package.py:18:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+ /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/extension2/package.py:18:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
- /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/external-buildable-with-variant/package.py:17:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+ /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/external-buildable-with-variant/package.py:17:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
- /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/external-common-openssl/package.py:13:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+ /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/external-common-openssl/package.py:13:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
- /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/external-common-perl/package.py:13:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+ /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/external-common-perl/package.py:13:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
- /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/external-common-python/package.py:13:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+ /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/external-common-python/package.py:13:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
- /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/external-common-python/package.py:14:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+ /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/external-common-python/package.py:14:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
... (truncated 92 lines) ...
comtypes (https://github.com/enthought/comtypes): 277.35x slower (0.1s -> 22.1s in a single noisy sample)
|
thinking about this more, i think we should avoid the i still think we should detect |
closing in favor of #1006 |
fixes #365
If project root is found, and ".venv" is found under project root, use that as default.
Project root is found if "pyrightconfig.json" or "pyproject.toml" is found. ".venv" can change to another name by change the '[tool.pyright] venv="venv_name"' in "pyproject.toml". But note that
uv
only support ".venv" so better stick with that.