-
Notifications
You must be signed in to change notification settings - Fork 159
Description
I was able to crash pyrefly but didn't really get why it happened.
The error is in title — Internal error: a variable has leaked from one module to another.
It happens only with this particular SQL Alchemy query
item_type_spent = (
select(
Client.id.label("client_id"),
SearchItem.item_type.label("item_type"),
Item.count.label("item_count"),
(
func.round(
(
func.sum(Deal.price * Deal.volume)
/ func.sum(Deal.volume)
),
2,
)
* Item.count
).label("current_spent"),
)
.select_from(Item)
.join(Client, Client.id == Item.client_id)
.join(Deal, Deal.item_id == Item.id)
.join(SearchItem, SearchItem.name == Item.name)
.where(
Deal.deal_currency == Client.currency,
Deal.deal_type == "buy",
Deal.closed == False, # noqa: E712
Item.count > 0,
)
.group_by(Client.id, Item.name, Item.count, SearchItem.item_type)
).cte("item_type_spent")
query = select(
item_type_spent.c.client_id,
item_type_spent.c.item_type,
func.sum(item_type_spent.c.item_count),
func.sum(item_type_spent.c.current_spent),
).group_by(item_type_spent.c.client_id, item_type_spent.c.item_type)
When I type dot .
after the group_by
section Pyrefly just crashes every time with the Internal Error.
The models are defined in another database-specific package and imported from there.
I also noticed that despite my pyproject.toml
configuration for Pyrefly I always see in LSP logs these lines:
Could not decode
LspConfig
from Null, skipping client configuration request: invalid type: null, expected struct LspConfig.
Populating up to 2000 files in the workspace ...
Prepare to check 2469 files.
And sometimes it leads to oserror 24 with too many files open.
