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

Function default_root_python_package_pyi

crates/ty/tests/cli/python_environment.rs:2181–2218  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2179/// Similarly, if `python/__init__.pyi` is present, it is considered a package and `python` is not added to search paths.
2180#[test]
2181fn default_root_python_package_pyi() -> anyhow::Result<()> {
2182 let case = CliTest::with_files([
2183 ("src/foo.py", "foo = 10"),
2184 ("python/__init__.pyi", ""),
2185 ("python/bar.py", "bar = 20"),
2186 (
2187 "python/test_bar.py",
2188 r#"
2189 from foo import foo
2190 from bar import bar # expected unresolved import
2191
2192 print(f"{foo} {bar}")
2193 "#,
2194 ),
2195 ])?;
2196
2197 assert_cmd_snapshot!(case.command(), @"
2198 success: false
2199 exit_code: 1
2200 ----- stdout -----
2201 error[import-not-found]: Cannot resolve imported module `bar`
2202 --> python/test_bar.py:3:6
2203 |
2204 3 | from bar import bar # expected unresolved import
2205 | ^^^
2206 info: Searched in the following paths during module resolution:
2207 info: 1. <temp_dir>/src (first-party code)
2208 info: 2. <temp_dir>/ (first-party code)
2209 info: 3. vendored://stdlib (stdlib typeshed stubs vendored by ty)
2210 info: make sure your Python environment is properly configured: https://docs.astral.sh/ty/modules/#python-environment
2211
2212 Found 1 diagnostic
2213
2214 ----- stderr -----
2215 ");
2216
2217 Ok(())
2218}
2219
2220#[test]
2221fn pythonpath_is_respected() -> anyhow::Result<()> {

Callers

nothing calls this directly

Calls 2

with_filesFunction · 0.85
OkClass · 0.85

Tested by

no test coverage detected