---
source: crates/ruff_linter/src/linter.rs
---
invalid-syntax: annotated name `a` can't be global
 --> resources/test/fixtures/semantic_errors/annotated_global.py:4:5
  |
2 | def f1():
3 |     global a
4 |     a: str = "foo"  # error
  |     ^
5 |
6 | b: int = 1
  |

invalid-syntax: annotated name `b` can't be global
  --> resources/test/fixtures/semantic_errors/annotated_global.py:10:9
   |
 8 |     def inner():
 9 |         global b
10 |         b: str = "nested"  # error
   |         ^
11 |
12 | c: int = 1
   |

invalid-syntax: annotated name `c` can't be global
  --> resources/test/fixtures/semantic_errors/annotated_global.py:15:5
   |
13 | def f2():
14 |     global c
15 |     c: list[str] = []  # error
   |     ^
16 |
17 | d: int = 1
   |

invalid-syntax: annotated name `d` can't be global
  --> resources/test/fixtures/semantic_errors/annotated_global.py:20:5
   |
18 | def f3():
19 |     global d
20 |     d: str  # error
   |     ^
21 |
22 | e: int = 1
   |

invalid-syntax: annotated name `g` can't be global
  --> resources/test/fixtures/semantic_errors/annotated_global.py:29:1
   |
27 | f: int = 1  # okay
28 |
29 | g: int = 1
   | ^
30 | global g  # error
   |

invalid-syntax: annotated name `x` can't be global
  --> resources/test/fixtures/semantic_errors/annotated_global.py:33:5
   |
32 | class C:
33 |     x: str
   |     ^
34 |     global x  # error
   |

invalid-syntax: annotated name `x` can't be global
  --> resources/test/fixtures/semantic_errors/annotated_global.py:38:5
   |
36 | class D:
37 |     global x  # error
38 |     x: str
   |     ^
   |
