Repository: astral-sh/ruff
File: crates/ruff_python_parser/src/semantic_errors.rs (Rust)

Code before:
            }
            SemanticSyntaxErrorKind::AnnotatedNonlocal(name) => {
                write!(f, "annotated name `{name}` can't be nonlocal")
            }
            SemanticSyntaxErrorKind::YieldFromInAsyncFunction => {
                f.write_str("`yield from` statement in async function; use `async for` instead")
            }
            SemanticSyntaxErrorKind::NonModuleImportStar(name) => {
                write!(f, "`from {name} import *` only allowed at module level")
            }
            SemanticSyntaxErrorKind::MultipleStarredExpressions => {
                write!(f, "Two starred expressions in assignment")
            }
            SemanticSyntaxErrorKind::FutureFeatureNotDefined(name) => {
                write!(f, "Future feature `{name}` is not defined")
            }
            SemanticSyntaxErrorKind::BreakOutsideLoop => f.write_str("`break` outside loop"),
            SemanticSyntaxErrorKind::ContinueOutsideLoop => f.write_str("`continue` outside loop"),
            SemanticSyntaxErrorKind::GlobalParameter(name) => {
                write!(f, "name `{name}` is parameter and global")
            }
            SemanticSyntaxErrorKind::DifferentMatchPatternBindings => {
                write!(f, "alternative patterns bind different names")
            }
            SemanticSyntaxErrorKind::NonlocalWithoutBinding(name) => {
                write!(f, "Nonlocal name `{name}` found without binding")
            }
        }
    }
}

impl Ranged for SemanticSyntaxError {
    fn range(&self) -> TextRange {
        self.range
    }
}

#[derive(Debug, Clone, PartialEq, Eq, Hash, get_size2::GetSize)]
pub enum SemanticSyntaxErrorKind {
    /// Represents the use of a `__future__` import after the beginning of a file.
    ///
    /// ## Examples
    ///
    /// ```python
    /// from pathlib import Path
    ///
    /// from __future__ import annotations
    /// ```
    ///
    /// This corresponds to the [`late-future-import`] (`F404`) rule in ruff.
    ///

Review comment (suggestion):
It looks like most of our other error messages start with a lowercase letter. I might just stick with the CPython error message here:

```pycon
>>> def f():
...     nonlocal x
...
  File "<python-input-0>", line 2
    nonlocal x
    ^^^^^^^^^^
SyntaxError: no binding for nonlocal 'x' found
```

```suggestion
                write!(f, "no binding for nonlocal `{name}` found")
```

Code after:
            }
            SemanticSyntaxErrorKind::AnnotatedNonlocal(name) => {
                write!(f, "annotated name `{name}` can't be nonlocal")
            }
            SemanticSyntaxErrorKind::YieldFromInAsyncFunction => {
                f.write_str("`yield from` statement in async function; use `async for` instead")
            }
            SemanticSyntaxErrorKind::NonModuleImportStar(name) => {
                write!(f, "`from {name} import *` only allowed at module level")
            }
            SemanticSyntaxErrorKind::MultipleStarredExpressions => {
                write!(f, "Two starred expressions in assignment")
            }
            SemanticSyntaxErrorKind::FutureFeatureNotDefined(name) => {
                write!(f, "Future feature `{name}` is not defined")
            }
            SemanticSyntaxErrorKind::BreakOutsideLoop => f.write_str("`break` outside loop"),
            SemanticSyntaxErrorKind::ContinueOutsideLoop => f.write_str("`continue` outside loop"),
            SemanticSyntaxErrorKind::GlobalParameter(name) => {
                write!(f, "name `{name}` is parameter and global")
            }
            SemanticSyntaxErrorKind::DifferentMatchPatternBindings => {
                write!(f, "alternative patterns bind different names")
            }
            SemanticSyntaxErrorKind::NonlocalWithoutBinding(name) => {
                write!(f, "no binding for nonlocal `{name}` found")
            }
        }
    }
}

impl Ranged for SemanticSyntaxError {
    fn range(&self) -> TextRange {
        self.range
    }
}

#[derive(Debug, Clone, PartialEq, Eq, Hash, get_size2::GetSize)]
pub enum SemanticSyntaxErrorKind {
    /// Represents the use of a `__future__` import after the beginning of a file.
    ///
    /// ## Examples
    ///
    /// ```python
    /// from pathlib import Path
    ///
    /// from __future__ import annotations
    /// ```
    ///
    /// This corresponds to the [`late-future-import`] (`F404`) rule in ruff.
    ///