facebook / facebook/pyrefly

no error on possibly undefined attribute

Open
#4,318 2 comments 0 reactions 1 assignee Claimed by @asukaminato0721 View on GitHub
stale typechecking
Dominant language
Rust
Stars
7k
Forks
519
PR merge metrics
No merged PRs in 30d

Description

> not just platform checks, any conditionally defined attributes:
>
> ```py
> def condition() -> bool:
> return False
>
> class A:
> if condition():
> c: int = 0
>
> A.c # no error, crashes at runtime
> ```
>
> ty's [`possibly-missing-attribute`](https://docs.astral.sh/ty/reference/rules/#possibly-missing-attribute) rule catches this

_Originally posted by @DetachHead in [#2558](https://github.com/facebook/pyrefly/issues/2558#issuecomment-4677703877)_

opening a new issue because the example here still doesn't report an error on 1.2.0-dev.3

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.