Pyright reportUnknownMemberType in Pyrefly
Pyright's reportUnknownMemberType fires when a member exists but its type
cannot be determined, both where the member is accessed and where it is
assigned. Pyrefly splits these into three kinds, and pyrefly init maps the rule
to all of them:
unknown-attribute-access for accesses,
unknown-attribute-type for
assignments of an unknown value to an unannotated attribute, and
unknown-from-error for members whose
type is unknown because it comes from an error, such as an unresolved import.
[errors]
unknown-attribute-access = "error"
unknown-attribute-type = "error"
unknown-from-error = "error"
All three kinds default to ignore, so a project that relied on Pyright's strict
unknown-member policy has to enable them explicitly. pyrefly init does
that for you when the Pyright config sets the rule.
Unknown is not the same as missing
class Dynamic:
value = some_untyped_factory()
item = Dynamic()
item.value # the member exists, but its type is unknown
item.does_not_exist # the member is missing
Pyrefly reports these as different kinds:
| Scenario | Pyrefly kind |
|---|---|
| An attribute whose type is unknown is accessed | unknown-attribute-access |
| An unannotated attribute is assigned a value of unknown type | unknown-attribute-type |
| The attribute does not exist | missing-attribute |
| An imported name is absent from a module | missing-module-attribute |
The attribute is implicitly Any-like because it was assigned None or () without an annotation | implicit-any-attribute |
Substituting missing-attribute for reportUnknownMemberType changes the
policy rather than preserving it.
Related unknown-type rules
| Pyright | Pyrefly |
|---|---|
reportUnknownMemberType | unknown-attribute-access, unknown-attribute-type, unknown-from-error |
reportUnknownVariableType | unknown-variable-type, unknown-return-type, unknown-from-error |
reportUnknownArgumentType | unknown-argument-type, unknown-from-error |
reportUnknownParameterType | implicit-any-parameter |
reportUnknownLambdaType | implicit-any-lambda, unknown-return-type, unknown-from-error |
Reduce unknown member types at the source
- install or improve package stubs;
- annotate factory return types;
- annotate class attributes explicitly;
- avoid replacing resolvable imports with
Any; - review decorators or framework behavior that generates members dynamically.
If the project previously relied on Pylance- or Pyright-specific behavior for generated members, exercise those frameworks in Pyrefly before weakening the diagnostic. Pyrefly models Pydantic, Django, and attrs directly, so an unknown member on a model or an ORM field is more likely a framework-support gap worth reporting than a reason to disable the rule project-wide.