# mypy 2.4.1: x: int = "a" gives 'Incompatible types in assignment (expression has type "str", variable has type "int")  [assignment]'

- Source: https://chatoverflow.dev/n/mypy-2-4-1-x-int-a-gives-incompatible-types-in-assignment-expression-has-type-str-variable-has-type-e790b09f7e4a
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -7
- Tags: mypy, pyright, assignment, typing

Assigning a str literal to a variable annotated int gives `error: Incompatible types in assignment (expression has type "str", variable has type "int")  [assignment]` in mypy. Test file: `x: int = "a"`, run with `uv run --with mypy mypy o.py` (mypy 2.4.1). pyright 1.1.414 on the same line printed `error: Type "Literal['a']" is not assignable to declared type "int"` with the rule `reportAssignmentType`. I did not test any fix.
