You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am not sure if it is intended and could not find similar issue reports:
When I type-narrow a global variable outside a function, pyrefly does not remember this narrowing inside the function. Note: For other scopes like for-loops it remembers it.
global_var: str|None=Noneifglobal_varisNone:
global_var=""lis_1:list[str]=[global_var] # no error in pyreflyifTrue:
lis_2:list[str]=[global_var] # no error in pyreflydeffun():
lis_3:list[str]=[global_var] # pyrefly warning: `list[str | None]` is not assignable to `list[str]`
Describe the Bug
I am not sure if it is intended and could not find similar issue reports:
When I type-narrow a global variable outside a function, pyrefly does not remember this narrowing inside the function. Note: For other scopes like for-loops it remembers it.
Sandbox Link
https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeSIA5lLtqlAPoBuqATogARwAurAPgDlc6GBwC8HISIA66WRDAdqteszYcIcScJiJZHA0pp1GLVuI7SQV2bKiaGARkT2eAbR6sAumLfKTat4cAMQc6LgcMKysuOYQ6BxkrDBgUKS26AocACqsAK66%2BoauDABMLprcHrw%2BfsaqZl4hYRFRMXEJSSlpGZgpHGB56AAUAJR6CcUOAMwV7p61-g1sTaFdqaQcAO5smeiUnAAGrlWeHHzaIl6HGlrh3ByocHAQlOio2LAc3BHHldXeQ4ZEAAGhA6zShB%2BAFsoBRQgAFUjJDZcDA4AgcADGwkglDyrFQ3AgwkIslCAGUYKIABbcbjEOCIAD0zIhpEIsUozJg6GZmFwWLgzJx6DxBKJJL5A1ijxY0A%2BX1F4sJxOEHFwxDV6DgZPQZG4NOEAFomFEXuqJFZpoRHKUbOg3G1YnAvLIhhBocRYtwYJhjZgIMkscSzRYAOSvcLJcOye7G5IARzyQb9xoA1jBSMbUFisfAtBJwztWOhY%2BgQABfMG50MwABi0BgFDQWDwRDIVaAA
(Only applicable for extension issues) IDE Information
No response