Skip to content

Pyrefly Cannot Correctly Figure Out Dependencies in Non-VSCode Editors #356

@Notenlish

Description

@Notenlish

Describe the Bug

(.venv) noten@noten:~/Documents/GitHub/hukuksuzlugun-bedeli$ ls
backend.sh  frontend.sh  pyproject.toml      README.md
backend   frontend    LICENSE      pyrightconfig.json

In my project, the backend module contains python code. Pyrefly cannot detect that I am using a virtualenv and therefore gives an error when I run pyrefly check, as it thinks I haven't installed those modules. My venv directory is .venv/.

I already have a pyproject.toml setup:

[tool.pyrefly]
search_path = ["backend/"]  # analyze these directories
#python_executable = ".venv/bin/python3"
# site_package_path=[".venv/lib/python3.12/site-packages"]
# python_interpreter=".venv/bin/python3"

I tried commenting and uncommenting the site_package_path and python_interpreter, it still doesn't work.
I am guessing I am missing something, what am I doing wrong?

(.venv) noten@noten:~/Documents/GitHub/hukuksuzlugun-bedeli$ pyrefly check
 INFO Checking project configured at `/home/noten/Documents/GitHub/hukuksuzlugun-bedeli/pyproject.toml`
ERROR /home/noten/Documents/GitHub/hukuksuzlugun-bedeli/backend/actions.py:2:21-27: Could not import `bcrypt` from `passlib` [missing-module-attribute]
ERROR /home/noten/Documents/GitHub/hukuksuzlugun-bedeli/backend/evdsclient.py:10:25-42: No attribute `adapters` in module `requests` [missing-attribute]
ERROR /home/noten/Documents/GitHub/hukuksuzlugun-bedeli/backend/evdsclient.py:17:14-25: Attribute `poolmanager` is implicitly defined by assignment in method `init_poolmanager`, which is not a constructor [implicitly-defined-attribute]
ERROR /home/noten/Documents/GitHub/hukuksuzlugun-bedeli/backend/evdsclient.py:55:14-21: Attribute `session` is implicitly defined by assignment in method `__create_session`, which is not a constructor [implicitly-defined-attribute]
ERROR /home/noten/Documents/GitHub/hukuksuzlugun-bedeli/backend/evdsclient.py:78:13-46: Item assignment is not supported on `DataFrame | Series | Unknown`
  Expected `__setitem__` to be a callable, got BoundMethod[DataFrame, (self: Self@DataFrame, key: Unknown, value: Unknown) -> None] | BoundMethod[Series, (self: Self@Series, key: Unknown, value: Unknown) -> None] | Unknown [not-callable]
ERROR /home/noten/Documents/GitHub/hukuksuzlugun-bedeli/backend/evdsclient.py:103:33-76: Object of class `ndarray` has no attribute `to_list` [missing-attribute]
ERROR /home/noten/Documents/GitHub/hukuksuzlugun-bedeli/backend/fetcher.py:208:27-58: Expected 0 type arguments for `FrequencyEVDS`, got 1 [bad-specialization]
ERROR /home/noten/Documents/GitHub/hukuksuzlugun-bedeli/backend/fetcher.py:208:41-57: Expected a type form, got instance of `FrequencyEnum` [not-a-type]
ERROR /home/noten/Documents/GitHub/hukuksuzlugun-bedeli/backend/main.py:53:5-23: Missing argument `self` in function `functools._Wrapped.__call__` [missing-argument]
ERROR /home/noten/Documents/GitHub/hukuksuzlugun-bedeli/backend/main.py:60:1-19: Expected `Ellipsis` to be a ParamSpec value in function `starlette.applications.Starlette.add_middleware` [bad-argument-type]
ERROR /home/noten/Documents/GitHub/hukuksuzlugun-bedeli/backend/main.py:61:5-19: Argument `type[CORSMiddleware]` is not assignable to parameter with type `_MiddlewareFactory[@_]` in function `starlette.applications.Starlette.add_middleware` [bad-argument-type]
ERROR /home/noten/Documents/GitHub/hukuksuzlugun-bedeli/backend/main.py:227:33-56: Item assignment is not supported on `dict[str, str]`
  Argument `list[@_]` is not assignable to parameter with type `str` in function `dict.__setitem__` [bad-argument-type]
ERROR /home/noten/Documents/GitHub/hukuksuzlugun-bedeli/backend/main.py:240:21-48: Item assignment is not supported on `dict[str, dict[str, list[Unknown]]]`
  Argument `dict[str, str]` is not assignable to parameter with type `dict[str, list[Unknown]]` in function `dict.__setitem__` [bad-argument-type]
ERROR /home/noten/Documents/GitHub/hukuksuzlugun-bedeli/backend/models.py:89:11-15: Class member `MetricDataPoint.Meta` overrides parent class `Model` in an inconsistent manner [bad-override]
 INFO 14 errors shown, 1 errors ignored, 15 modules, 1,610 transitive dependencies, 753,673 lines, took 1.76s (checking 1.06s; listing 0.69s), peak memory physical 494.4 MiB

If it helps, I am on Linux Mint 22.1 with Zed editor, however I don't think it's something related to Zed.

Sandbox Link

No response

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions