Skip to main content

Mypy Error Codes to Pyrefly

Mypy configs often set severity policy by error code, in disable_error_code, enable_error_code, and per-module overrides. Pyrefly expresses the same policy with error kinds, which use different names, so pyrefly init has to translate each code as it converts the config.

Some mypy error codes are not able to be translated by pyrefly init or when the two tools group the same scenario differently a translated code is not always an exact equivalent. Review the table below to compare mypy and Pyrefly error codes.

How to read the table

  • Automatic: pyrefly init translates the code.
  • Manual: a useful Pyrefly kind exists, but pyrefly init does not translate it, so you should update your Pyrefly config manually.
  • Split / broad / related: a similar error kind exists in Pyrefly but do not assume equal coverage in both directions.
  • Not mapped: no current one-to-one translation.
warning

This table describes configuration migration. Enabling the mapped Pyrefly kind does not make every diagnostic identical to mypy's.

Complete mapping

Mypy codeClosest Pyrefly kind(s)Config migrationFidelityNotes
attr-definedmissing-attributeAutomaticDirect-ishPyrefly reports missing module attributes as missing-module-attribute.
name-definedunknown-nameAutomaticDirect
call-argbad-argument-countAutomaticPartialPyrefly also has more specific call-shape kinds such as missing-argument, unexpected-keyword, and unexpected-positional-argument.
arg-typebad-argument-typeAutomaticDirect-ish
call-overloadno-matching-overloadAutomaticDirect-ishPyrefly may also emit incompatible-overload-residual in higher-order generic calls.
valid-typeinvalid-annotationAutomaticBroadSome invalid type forms are split into invalid-literal, invalid-type-alias, invalid-type-var, or not-a-type.
nonetype-typeinvalid-annotationManualRelatedNo dedicated one-to-one kind.
var-annotatedimplicit-any-empty-container, implicit-any, or a context-specific errorManualRelatedPyrefly splits implicit Any by source rather than using one "annotation required" code.
overridebad-overrideAutomaticDirect-ishPyrefly has sub-kinds for mutable attributes and parameter names.
returnbad-returnAutomaticBroadMypy uses this for missing-return paths; Pyrefly groups incompatible and missing returns under bad-return.
return-valuebad-returnAutomaticDirect-ish
assignmentbad-assignmentAutomaticDirect-ish
method-assignbad-assignment or read-onlyManualRelatedDepends on whether the failure is type incompatibility or attempted mutation.
type-argimplicit-any-type-argumentAutomaticDirect-ish
type-varbad-specializationAutomaticPartialPyrefly uses invalid-type-var for many TypeVar definition and usage errors.
union-attrmissing-attributeAutomaticDirect-ish
indexbad-index, unsupported-operationAutomaticSplitOne mypy code maps to two Pyrefly kinds.
operatorunsupported-operationAutomaticDirect-ish
list-itemUsually bad-assignment or bad-argument-typeManualNo stable 1:1The Pyrefly kind depends on the surrounding expected type.
dict-itembad-typed-dictAutomaticApproximateThis is what the converter emits, but ordinary dict-literal item errors are not semantically identical to bad-typed-dict; review the generated override.
typeddict-itembad-typed-dict or bad-typed-dict-keyManualRelated
typeddict-unknown-keybad-typed-dict-keyAutomaticDirect
has-typeNo direct equivalentNot mappedNonePyrefly reports a more specific inference or definition error instead.
importmissing-importAutomaticBroadMypy's umbrella import code also covers missing stubs; Pyrefly separates missing-import and untyped-import.
import-not-foundmissing-importAutomaticDirect
import-untypeduntyped-importAutomaticDirect-ish
no-redefredefinitionManualDirect-ishThe converter does not translate no-redef.
func-returns-valueUsually bad-assignment or bad-returnManualNo stable 1:1
abstractbad-instantiationAutomaticDirect-ish
type-abstractbad-instantiationManualRelatedPyrefly has no separate "abstract class object passed where a concrete type is expected" kind.
valid-newtypeinvalid-argumentManualRelated
str-formatNo direct equivalentNot mappedNoneUse runtime tests or a linter for format-string checks.
str-bytes-safeNo direct equivalentNot mappedNone
exit-returnbad-returnManualRelated
literal-requiredinvalid-literalManualDirect-ish
unused-coroutineunused-coroutineAutomaticDirect
empty-bodyempty-bodyManualDirect
safe-superabstract-method-callManualRelated
top-level-awaitnot-asyncAutomaticDirect-ish
await-not-asyncnot-asyncAutomaticDirect-ish
no-untyped-defimplicit-any-parameter, unannotated-returnAutomaticSplitThe implicit-any umbrella enables every implicit-Any sub-kind, which is broader than mypy's code.
no-untyped-callNo direct equivalentNot mappedNonePyrefly reports the downstream unknown/Any consequences rather than the call itself.
redundant-castredundant-castAutomaticDirect
assert-typeassert-typeAutomaticDirect
comparison-overlapincompatible-comparison, unnecessary-comparisonManualSplit/related
no-any-unimporteduntyped-import, missing-import, and the implicit-Any kindsManualNo exact 1:1The tools model import-derived Any differently.
no-any-returnno-any-returnAutomaticDirect-ishPyrefly has explicit and implicit sub-kinds under this umbrella.
unreachableunreachableManualDirect-ishPyrefly also has unreachable-match-case.
annotation-uncheckedNo direct equivalentNot mappedNonePyrefly's checking of unannotated functions is controlled by check-unannotated-defs.
typeddict-readonly-mutatedread-onlyAutomaticDirect-ish
possibly-undefinedunbound-nameAutomaticDirect-ish
redundant-exprredundant-conditionAutomaticRelated
truthy-boolredundant-conditionAutomaticRelated
truthy-functionredundant-conditionAutomaticRelated
truthy-iterableredundant-conditionAutomaticRelated
str-unpackstring-as-iterableManualRelated
name-matchname-mismatchAutomaticDirect
no-overload-implinvalid-overloadAutomaticDirect
ignore-without-codeNo direct equivalentNot mappedNonePyrefly can detect unused or misplaced ignores, but not this exact policy.
unused-awaitableunused-coroutineAutomaticRelatedMypy's awaitable rule is broader than coroutines.
redundant-selfNo direct equivalentNot mappedNone
used-before-defunbound-nameAutomaticDirect-ish
unused-ignoreunused-type-ignore or unused-ignoreManualDirect-ishChoose based on the ignore syntax you are enforcing.
explicit-overridemissing-override-decoratorManualDirect
unimported-revealunimported-directiveManualDirect-ish
mutable-overridebad-override-mutable-attributeAutomaticDirect
exhaustive-matchnon-exhaustive-matchManualDirect
metaclassinvalid-inheritanceAutomaticRelated
maybe-unrecognized-str-typeforminvalid-annotation or not-a-typeManualRelated
syntaxparse-errorAutomaticDirect-ishPyrefly also has invalid-syntax for checker-level syntax restrictions.
miscNo direct umbrellaNot mappedNoneMap the underlying scenario, not mypy's catch-all code.
overload-cannot-matchinconsistent-overloadManualRelatedNo exact one-to-one rule.
overload-overlapinconsistent-overloadManualRelatedNo exact one-to-one rule.
prop-decoratorinvalid-decoratorManualRelated
untyped-decoratoruntyped-function-decoratorManualDirect-ishClass decorators use untyped-class-decorator.
narrowed-type-not-subtypeNo direct equivalentNot mappedNoneA more specific annotation or argument error may be emitted instead.
explicit-anyexplicit-anyAutomaticDirect
deprecateddeprecatedAutomaticDirect

Configuration example

Mypy:

[tool.mypy]
enable_error_code = ["explicit-override", "possibly-undefined"]
disable_error_code = ["import-untyped"]

A reviewed Pyrefly equivalent is:

[errors]
missing-override-decorator = "error"
unbound-name = "error"
untyped-import = "ignore"

explicit-override is not in the converter's code map even though Pyrefly has a close equivalent, so missing-override-decorator has to be added by hand.

Strictness flags that become error kinds

pyrefly init also converts a handful of mypy flags directly into error severities:

Mypy flagGenerated Pyrefly policyCaveat
warn_return_any or strictno-any-return = "error"Pyrefly has explicit and implicit sub-kinds
warn_redundant_casts or strictredundant-cast = "warn"Generated at warning severity, not error
disallow_untyped_defs, disallow_incomplete_defs, or strictimplicit-any-parameter and unannotated-return as errorsThe two tools divide partially annotated definitions differently
disallow_any_generics or strictimplicit-any = "error"This umbrella is broader than missing generic arguments alone
disallow_any_explicitexplicit-any = "error"Not enabled by mypy strict
allow_redefinitionsredefinition = "ignore"The converter reads this key, not mypy's documented allow_redefinition
note

Last reviewed against upstream mypy error-code documentation and Pyrefly's migration source on 2026-08-08.