Detect circular references
Your task
A feature-flag file is lines of the exact form "KEY=value" (split on the first "="). Values may mention other keys with the syntax "OTHER". Your linter must reject files where following such mentions can loop forever. Treat each mention of an EXISTING key as an edge from the defining key to the mentioned key; mentions of undefined names are harmless and ignored, as is any malformed "{" without a closing "}". Return true when the resulting graph contains a cycle (a key mentioning itself counts), false otherwise.
Examples
has_circular_reference(lines: list[str]) -> boolExample 1
Input
has_circular_reference(["A=${B}", "B=${A}"])Output
TrueExample 2
Input
has_circular_reference(["A=${B}", "B=ok"])Output
False