Describe the Bug
Given the following code:
from typing import Any
def from_response(response: dict[str, Any]) -> None:
response["meta"] = {"time_to_live": None}
Pyrefly reports:
❯ target\debug\pyrefly.exe --version
pyrefly 1.2.0-dev.3
❯ target\debug\pyrefly.exe check ../privatebin/t.py
ERROR Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
--> C:\Users\raven\dev\github\privatebin\t.py:7:41
|
7 | response["meta"] = {"time_to_live": None}
| ^^^^
|
Consider adding a type annotation or initializing with a non-empty value
INFO 1 error
This looks closely related to #3593, which was closed as fixed.
To check whether this was already addressed by that fix, I built Pyrefly from commit c28caa7, but I was still able to reproduce the issue there.
In this case, response is explicitly annotated as dict[str, Any], so I would expect the assigned value {"time_to_live": None} to be accepted without an implicit-any-empty-container error.
Sandbox Link
https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeS4ATrgLYAEALqcROgOZ0Q3G6UN0BBdKQA6lEejETMMMHTDUaAfUrwe6ODAAUquOs2I6mCAGMGAbTgNKAGkHCAugEo6AWgB8dAHK50MRFLodMF0uvow5iIgNDAMqFEOdAC8dMBRDFwwSgy4SlAQAG4wUYY%2BfgC%2BgSA2IGSqYFCkhDk0UBQAxHQACqT1jXRoWHj4dCa%2BkGwArpSoGb6EEp0AyjAwdAAWDAzEcIgA9Ht1so2EvGx7MOh7mLgmcHtj6BPTsxC%2Be-K8dKgFqNCo2Fgo3GECmMzmQVwxAhcAW6DIDHWvlcRUocDeQRSUQAzIQAIwAJiiEmIuliyToUSslFMDGJ6HMMEo1DRDgkk3QXB4fBgmFcxlUZkKaxSAHJQeheDBRRJJQxXKoAI6TCCqPkAaxgpFcqBMJngcApooA7qhKOgZegQOUarqMkUAGLQGAUQY4AgkcjlIA
(Only applicable for extension issues) IDE Information
No response
Describe the Bug
Given the following code:
Pyrefly reports:
This looks closely related to #3593, which was closed as fixed.
To check whether this was already addressed by that fix, I built Pyrefly from commit c28caa7, but I was still able to reproduce the issue there.
In this case,
responseis explicitly annotated asdict[str, Any], so I would expect the assigned value{"time_to_live": None}to be accepted without animplicit-any-empty-containererror.Sandbox Link
https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeS4ATrgLYAEALqcROgOZ0Q3G6UN0BBdKQA6lEejETMMMHTDUaAfUrwe6ODAAUquOs2I6mCAGMGAbTgNKAGkHCAugEo6AWgB8dAHK50MRFLodMF0uvow5iIgNDAMqFEOdAC8dMBRDFwwSgy4SlAQAG4wUYY%2BfgC%2BgSA2IGSqYFCkhDk0UBQAxHQACqT1jXRoWHj4dCa%2BkGwArpSoGb6EEp0AyjAwdAAWDAzEcIgA9Ht1so2EvGx7MOh7mLgmcHtj6BPTsxC%2Be-K8dKgFqNCo2Fgo3GECmMzmQVwxAhcAW6DIDHWvlcRUocDeQRSUQAzIQAIwAJiiEmIuliyToUSslFMDGJ6HMMEo1DRDgkk3QXB4fBgmFcxlUZkKaxSAHJQeheDBRRJJQxXKoAI6TCCqPkAaxgpFcqBMJngcApooA7qhKOgZegQOUarqMkUAGLQGAUQY4AgkcjlIA
(Only applicable for extension issues) IDE Information
No response