MCPcopy Create free account
hub / github.com/astral-sh/ruff / python_magic_globals

Function python_magic_globals

crates/ruff_python_stdlib/src/builtins.rs:240–259  ·  view source on GitHub ↗

Return the list of magic globals for the given Python minor version.

(minor_version: u8)

Source from the content-addressed store, hash-verified

238
239/// Return the list of magic globals for the given Python minor version.
240pub fn python_magic_globals(minor_version: u8) -> impl Iterator<Item = &'static str> {
241 let py314_magic_globals = if minor_version >= 14 {
242 Some(PY314_PLUS_MAGIC_GLOBALS)
243 } else {
244 None
245 };
246
247 let pre_py315_magic_globals = if minor_version < 15 {
248 Some(PRE_PY315_MAGIC_GLOBALS)
249 } else {
250 None
251 };
252
253 py314_magic_globals
254 .into_iter()
255 .chain(pre_py315_magic_globals)
256 .flatten()
257 .chain(MAGIC_GLOBALS)
258 .copied()
259}
260
261/// Returns `true` if the given name is that of a Python builtin.
262///

Callers 2

newMethod · 0.85
is_builtin_nameMethod · 0.85

Calls 2

flattenMethod · 0.80
into_iterMethod · 0.45

Tested by

no test coverage detected