diff --git a/crates/ty/docs/rules.md b/crates/ty/docs/rules.md index fd243b89697dbc..7769d823bf1836 100644 --- a/crates/ty/docs/rules.md +++ b/crates/ty/docs/rules.md @@ -1575,9 +1575,9 @@ class Person(TypedDict): alice = Person(name="Alice", age=30) alice["height"] # KeyError: 'height' -bob: Person = { "name": "Bob", "age": 30 } # typo! +bob: Person = { "namee": "Bob", "age": 30 } # typo! -carol = Person(name="Carol", age=25) # typo! +carol = Person(name="Carol", aeg=25) # typo! ``` ## `invalid-legacy-positional-parameter` diff --git a/crates/ty_python_semantic/src/types/diagnostic.rs b/crates/ty_python_semantic/src/types/diagnostic.rs index 20f5a5bb863b83..bf3a44149b1d75 100644 --- a/crates/ty_python_semantic/src/types/diagnostic.rs +++ b/crates/ty_python_semantic/src/types/diagnostic.rs @@ -801,9 +801,9 @@ declare_lint! { /// alice = Person(name="Alice", age=30) /// alice["height"] # KeyError: 'height' /// - /// bob: Person = { "name": "Bob", "age": 30 } # typo! + /// bob: Person = { "namee": "Bob", "age": 30 } # typo! /// - /// carol = Person(name="Carol", age=25) # typo! + /// carol = Person(name="Carol", aeg=25) # typo! /// ``` pub(crate) static INVALID_KEY = { summary: "detects invalid subscript accesses or TypedDict literal keys", diff --git a/ty.schema.json b/ty.schema.json index 749231008e0ed5..9ff5db3cbae2c1 100644 --- a/ty.schema.json +++ b/ty.schema.json @@ -816,7 +816,7 @@ }, "invalid-key": { "title": "detects invalid subscript accesses or TypedDict literal keys", - "description": "## What it does\nChecks for subscript accesses with invalid keys and `TypedDict` construction with an\nunknown key.\n\n## Why is this bad?\nSubscripting with an invalid key will raise a `KeyError` at runtime.\n\nCreating a `TypedDict` with an unknown key is likely a mistake; if the `TypedDict` is\n`closed=true` it also violates the expectations of the type.\n\n## Examples\n```python\nfrom typing import TypedDict\n\nclass Person(TypedDict):\n name: str\n age: int\n\nalice = Person(name=\"Alice\", age=30)\nalice[\"height\"] # KeyError: 'height'\n\nbob: Person = { \"name\": \"Bob\", \"age\": 30 } # typo!\n\ncarol = Person(name=\"Carol\", age=25) # typo!\n```", + "description": "## What it does\nChecks for subscript accesses with invalid keys and `TypedDict` construction with an\nunknown key.\n\n## Why is this bad?\nSubscripting with an invalid key will raise a `KeyError` at runtime.\n\nCreating a `TypedDict` with an unknown key is likely a mistake; if the `TypedDict` is\n`closed=true` it also violates the expectations of the type.\n\n## Examples\n```python\nfrom typing import TypedDict\n\nclass Person(TypedDict):\n name: str\n age: int\n\nalice = Person(name=\"Alice\", age=30)\nalice[\"height\"] # KeyError: 'height'\n\nbob: Person = { \"namee\": \"Bob\", \"age\": 30 } # typo!\n\ncarol = Person(name=\"Carol\", aeg=25) # typo!\n```", "default": "error", "oneOf": [ {