Add note about how Ruff handles PYI files wrt target version (#13111)

Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
This commit is contained in:
Calum Young 2024-08-27 18:28:22 +01:00 committed by GitHub
parent aba1802828
commit eb3dc37faa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View file

@ -308,6 +308,16 @@ pub struct Options {
///
/// If both are specified, `target-version` takes precedence over
/// `requires-python`.
///
/// Note that a stub file can [sometimes make use of a typing feature](https://typing.readthedocs.io/en/latest/spec/distributing.html#syntax)
/// before it is available at runtime, as long as the stub does not make
/// use of new *syntax*. For example, a type checker will understand
/// `int | str` in a stub as being a `Union` type annotation, even if the
/// type checker is run using Python 3.9, despite the fact that the `|`
/// operator can only be used to create union types at runtime on Python
/// 3.10+. As such, Ruff will often recommend newer features in a stub
/// file than it would for an equivalent runtime file with the same target
/// version.
#[option(
default = r#""py38""#,
value_type = r#""py37" | "py38" | "py39" | "py310" | "py311" | "py312""#,