# SIM910 {}.get(key, None) # SIM910 {}.get("key", None) # OK {}.get(key) # OK {}.get("key") # OK {}.get(key, False) # OK {}.get("key", False) # SIM910 if a := {}.get(key, None): pass # SIM910 a = {}.get(key, None) # SIM910 ({}).get(key, None) # SIM910 ages = {"Tom": 23, "Maria": 23, "Dog": 11} age = ages.get("Cat", None) # OK ages = ["Tom", "Maria", "Dog"] age = ages.get("Cat", None) # SIM910 def foo(**kwargs): a = kwargs.get('a', None) # SIM910 def foo(some_dict: dict): a = some_dict.get('a', None) # OK def foo(some_other: object): a = some_other.get('a', None) # OK def foo(some_other): a = some_other.get('a', None) # https://github.com/astral-sh/ruff/issues/18777 def foo(): dict = {"Tom": 23, "Maria": 23, "Dog": 11} age = dict.get("Cat", None) # https://github.com/astral-sh/ruff/issues/20341 # Method call as key ages = {"Tom": 23, "Maria": 23, "Dog": 11} key_source = {"Thomas": "Tom"} age = ages.get(key_source.get("Thomas", "Tom"), None) # Property access as key class Data: def __init__(self): self.name = "Tom" data = Data() ages = {"Tom": 23, "Maria": 23, "Dog": 11} age = ages.get(data.name, None) # Complex expression as key ages = {"Tom": 23, "Maria": 23, "Dog": 11} age = ages.get("Tom" if True else "Maria", None) # Function call as key def get_key(): return "Tom" ages = {"Tom": 23, "Maria": 23, "Dog": 11} age = ages.get(get_key(), None)