mirror of
https://github.com/django-components/django-components.git
synced 2025-09-20 04:39:45 +00:00
refactor: replace isort, black and flake8 with ruff (#1346)
Some checks are pending
Docs - build & deploy / docs (push) Waiting to run
Run tests / build (ubuntu-latest, 3.10) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.11) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.12) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.13) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.8) (push) Waiting to run
Run tests / test_sampleproject (3.13) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.9) (push) Waiting to run
Run tests / build (windows-latest, 3.10) (push) Waiting to run
Run tests / build (windows-latest, 3.11) (push) Waiting to run
Run tests / build (windows-latest, 3.12) (push) Waiting to run
Run tests / build (windows-latest, 3.13) (push) Waiting to run
Run tests / build (windows-latest, 3.8) (push) Waiting to run
Run tests / build (windows-latest, 3.9) (push) Waiting to run
Run tests / test_docs (3.13) (push) Waiting to run
Some checks are pending
Docs - build & deploy / docs (push) Waiting to run
Run tests / build (ubuntu-latest, 3.10) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.11) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.12) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.13) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.8) (push) Waiting to run
Run tests / test_sampleproject (3.13) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.9) (push) Waiting to run
Run tests / build (windows-latest, 3.10) (push) Waiting to run
Run tests / build (windows-latest, 3.11) (push) Waiting to run
Run tests / build (windows-latest, 3.12) (push) Waiting to run
Run tests / build (windows-latest, 3.13) (push) Waiting to run
Run tests / build (windows-latest, 3.8) (push) Waiting to run
Run tests / build (windows-latest, 3.9) (push) Waiting to run
Run tests / test_docs (3.13) (push) Waiting to run
This commit is contained in:
parent
5279fd372a
commit
f100cc1836
128 changed files with 3076 additions and 2599 deletions
|
@ -3,22 +3,22 @@
|
|||
from functools import lru_cache
|
||||
from importlib import import_module
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Optional, Union
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
|
||||
import griffe
|
||||
import yaml # type: ignore[import-untyped]
|
||||
|
||||
|
||||
@lru_cache()
|
||||
@lru_cache
|
||||
def load_config() -> Dict:
|
||||
mkdocs_config_str = Path("mkdocs.yml").read_text()
|
||||
# NOTE: Use BaseLoader to avoid resolving tags like `!ENV`
|
||||
# See https://stackoverflow.com/questions/45966633/yaml-error-could-not-determine-a-constructor-for-the-tag
|
||||
mkdocs_config = yaml.load(mkdocs_config_str, yaml.BaseLoader)
|
||||
mkdocs_config = yaml.load(mkdocs_config_str, yaml.BaseLoader) # noqa: S506
|
||||
return mkdocs_config
|
||||
|
||||
|
||||
@lru_cache()
|
||||
@lru_cache
|
||||
def find_plugin(name: str) -> Optional[Dict]:
|
||||
config = load_config()
|
||||
plugins: List[Union[str, Dict[str, Dict]]] = config.get("plugins", [])
|
||||
|
@ -27,8 +27,8 @@ def find_plugin(name: str) -> Optional[Dict]:
|
|||
|
||||
for plugin in plugins:
|
||||
if isinstance(plugin, str):
|
||||
plugin = {plugin: {}}
|
||||
plugin_name, plugin_conf = list(plugin.items())[0]
|
||||
plugin = {plugin: {}} # noqa: PLW2901
|
||||
plugin_name, plugin_conf = next(iter(plugin.items()))
|
||||
if plugin_name == name:
|
||||
return plugin_conf
|
||||
|
||||
|
@ -43,7 +43,7 @@ def get_mkdocstrings_plugin_handler_options() -> Optional[Dict]:
|
|||
return plugin.get("handlers", {}).get("python", {}).get("options", {})
|
||||
|
||||
|
||||
def import_object(obj: griffe.Object):
|
||||
def import_object(obj: griffe.Object) -> Any:
|
||||
module = import_module(obj.module.path)
|
||||
runtime_obj = getattr(module, obj.name)
|
||||
return runtime_obj
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue