MCPcopy Index your code
hub / github.com/RustPython/RustPython / feature_version_from_arg

Function feature_version_from_arg

crates/vm/src/stdlib/builtins.rs:427–443  ·  view source on GitHub ↗
(
        feature_version: OptionalArg<i32>,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

425
426 #[cfg(feature = "ast")]
427 fn feature_version_from_arg(
428 feature_version: OptionalArg<i32>,
429 vm: &VirtualMachine,
430 ) -> PyResult<Option<ruff_python_ast::PythonVersion>> {
431 let minor = match feature_version.into_option() {
432 Some(minor) => minor,
433 None => return Ok(None),
434 };
435
436 if minor < 0 {
437 return Ok(None);
438 }
439
440 let minor = u8::try_from(minor)
441 .map_err(|_| vm.new_value_error("compile() _feature_version out of range"))?;
442 Ok(Some(ruff_python_ast::PythonVersion { major: 3, minor }))
443 }
444
445 #[pyfunction]
446 fn delattr(obj: PyObjectRef, attr: PyObjectRef, vm: &VirtualMachine) -> PyResult<()> {

Callers 1

compileFunction · 0.85

Calls 2

into_optionMethod · 0.80
SomeClass · 0.50

Tested by

no test coverage detected