-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #171 from Glyphack/import-resolver
- Loading branch information
Showing
54 changed files
with
3,081 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
name = "ruff_python_resolver" | ||
version = "0.0.0" | ||
description = "Mirror of Python module resolver for Ruff. Do not use this I don't own the code." | ||
edition = "2021" | ||
|
||
[dependencies] | ||
log = { workspace = true } | ||
|
||
[dev-dependencies] | ||
env_logger = "0.10.0" | ||
tempfile = "3.6.0" | ||
insta = { workspace = true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# airflow | ||
|
||
This is a mock subset of the Airflow repository, used to test module resolution. |
1 change: 1 addition & 0 deletions
1
ruff_python_import_resolver/resources/test/airflow/airflow/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
1 change: 1 addition & 0 deletions
1
ruff_python_import_resolver/resources/test/airflow/airflow/api/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
1 change: 1 addition & 0 deletions
1
ruff_python_import_resolver/resources/test/airflow/airflow/api/common/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
14 changes: 14 additions & 0 deletions
14
ruff_python_import_resolver/resources/test/airflow/airflow/api/common/mark_tasks.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Standard library. | ||
import os | ||
|
||
# First-party. | ||
from airflow.jobs.scheduler_job_runner import SchedulerJobRunner | ||
|
||
# Stub file. | ||
from airflow.compat.functools import cached_property | ||
|
||
# Namespace package. | ||
from airflow.providers.google.cloud.hooks.gcs import GCSHook | ||
|
||
# Third-party. | ||
from sqlalchemy.orm import Query |
16 changes: 16 additions & 0 deletions
16
ruff_python_import_resolver/resources/test/airflow/airflow/compat/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. |
1 change: 1 addition & 0 deletions
1
ruff_python_import_resolver/resources/test/airflow/airflow/compat/functools.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Empty file included to support filesystem-based resolver tests.""" |
1 change: 1 addition & 0 deletions
1
ruff_python_import_resolver/resources/test/airflow/airflow/compat/functools.pyi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Empty file included to support filesystem-based resolver tests.""" |
Empty file.
1 change: 1 addition & 0 deletions
1
ruff_python_import_resolver/resources/test/airflow/airflow/jobs/scheduler_job_runner.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Empty file included to support filesystem-based resolver tests.""" |
Empty file.
Empty file.
Empty file.
1 change: 1 addition & 0 deletions
1
...python_import_resolver/resources/test/airflow/airflow/providers/google/cloud/hooks/gcs.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Empty file included to support filesystem-based resolver tests.""" |
1 change: 1 addition & 0 deletions
1
...s/test/airflow/venv/lib/python3.11/site-packages/_watchdog_fsevents.cpython-311-darwin.so
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Empty file included to support filesystem-based resolver tests. |
Empty file.
Empty file.
1 change: 1 addition & 0 deletions
1
...ources/test/airflow/venv/lib/python3.11/site-packages/orjson/orjson.cpython-311-darwin.so
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Empty file included to support filesystem-based resolver tests. |
Empty file.
1 change: 1 addition & 0 deletions
1
..._resolver/resources/test/airflow/venv/lib/python3.11/site-packages/sqlalchemy/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
Empty file.
1 change: 1 addition & 0 deletions
1
..._resolver/resources/test/airflow/venv/lib/python3.11/site-packages/sqlalchemy/orm/base.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Empty file included to support filesystem-based resolver tests.""" |
1 change: 1 addition & 0 deletions
1
...ver/resources/test/airflow/venv/lib/python3.11/site-packages/sqlalchemy/orm/dependency.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Empty file included to support filesystem-based resolver tests.""" |
1 change: 1 addition & 0 deletions
1
...resolver/resources/test/airflow/venv/lib/python3.11/site-packages/sqlalchemy/orm/query.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Empty file included to support filesystem-based resolver tests.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use std::path::PathBuf; | ||
|
||
pub struct Config { | ||
/// Path to use for typeshed definitions. | ||
pub typeshed_path: Option<PathBuf>, | ||
|
||
/// Path to custom typings (stub) modules. | ||
pub stub_path: Option<PathBuf>, | ||
|
||
/// Path to a directory containing one or more virtual environment | ||
/// directories. This is used in conjunction with the "venv" name in | ||
/// the config file to identify the python environment used for resolving | ||
/// third-party modules. | ||
pub venv_path: Option<PathBuf>, | ||
|
||
/// Default venv environment. | ||
pub venv: Option<PathBuf>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use std::path::PathBuf; | ||
|
||
use crate::{python_version::PythonVersion, python_platform::PythonPlatform}; | ||
|
||
|
||
#[derive(Debug)] | ||
pub struct ExecutionEnvironment { | ||
/// The root directory of the execution environment. | ||
pub root: PathBuf, | ||
|
||
/// The Python version of the execution environment. | ||
pub python_version: PythonVersion, | ||
|
||
/// The Python platform of the execution environment. | ||
pub python_platform: PythonPlatform, | ||
|
||
/// The extra search paths of the execution environment. | ||
pub extra_paths: Vec<PathBuf>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//! Expose the host environment to the resolver. | ||
|
||
use std::path::PathBuf; | ||
|
||
use crate::python_version::PythonVersion; | ||
use crate::python_platform::PythonPlatform; | ||
|
||
/// A trait to expose the host environment to the resolver. | ||
pub trait Host { | ||
/// The search paths to use when resolving Python modules. | ||
fn python_search_paths(&self) -> Vec<PathBuf>; | ||
|
||
/// The Python version to use when resolving Python modules. | ||
fn python_version(&self) -> PythonVersion; | ||
|
||
/// The OS platform to use when resolving Python modules. | ||
fn python_platform(&self) -> PythonPlatform; | ||
} | ||
|
||
/// A host that exposes a fixed set of search paths. | ||
pub struct StaticHost { | ||
search_paths: Vec<PathBuf>, | ||
} | ||
|
||
impl StaticHost { | ||
pub fn new(search_paths: Vec<PathBuf>) -> Self { | ||
Self { search_paths } | ||
} | ||
} | ||
|
||
impl Host for StaticHost { | ||
fn python_search_paths(&self) -> Vec<PathBuf> { | ||
self.search_paths.clone() | ||
} | ||
|
||
fn python_version(&self) -> PythonVersion { | ||
PythonVersion::Py312 | ||
} | ||
|
||
fn python_platform(&self) -> PythonPlatform { | ||
PythonPlatform::Darwin | ||
} | ||
} |
Oops, something went wrong.