sys.platform documentation

This commit is contained in:
David Peter
2024-12-18 10:31:08 +01:00
parent 12f139df87
commit 9a1d1ea33b
2 changed files with 7 additions and 3 deletions

View File

@@ -9,7 +9,11 @@ pub enum PythonPlatform {
/// Do not make any assumptions about the target platform.
#[default]
All,
/// Assume a target platform like `linux`, `darwin`, `win32`, etc.
/// Assume a specific target platform like `linux`, `darwin` or `win32`.
///
/// We use a string (instead of individual enum variants), as the set of possible platforms
/// may change over time. See <https://docs.python.org/3/library/sys.html#sys.platform> for
/// some known platform identifiers.
#[cfg_attr(feature = "serde", serde(untagged))]
Individual(String),
Identifier(String),
}

View File

@@ -139,7 +139,7 @@ fn symbol<'db>(db: &'db dyn Db, scope: ScopeId<'db>, name: &str) -> Symbol<'db>
&& file_to_module(db, scope.file(db)).is_some_and(|module| module.name() == "sys")
{
match Program::get(db).python_platform(db) {
crate::PythonPlatform::Individual(platform) => {
crate::PythonPlatform::Identifier(platform) => {
return Symbol::Type(
Type::StringLiteral(StringLiteralType::new(db, platform.as_str())),
Boundness::Bound,