Skip to content

Commit

Permalink
chore: enable ruff TYPE_CHECKING option
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed Dec 14, 2023
1 parent 756e6c4 commit 7d0f0aa
Show file tree
Hide file tree
Showing 72 changed files with 322 additions and 145 deletions.
6 changes: 4 additions & 2 deletions mknodes/basenodes/_mkdocstrings/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
from __future__ import annotations

from collections.abc import Callable
import os
import types

import griffe
from typing import Any, Literal
from typing import Any, Literal, TYPE_CHECKING

from mknodes.basenodes import mknode
from mknodes.utils import classhelpers, log, reprhelpers, resources

if TYPE_CHECKING:
import os


logger = log.get_logger(__name__)

Expand Down
6 changes: 4 additions & 2 deletions mknodes/basenodes/mkadmonition/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

import textwrap

from typing import Any, Literal
from typing import Any, Literal, TYPE_CHECKING

from mknodes.basenodes import mkcontainer, mknode
from mknodes.data import datatypes
from mknodes.utils import log, resources

if TYPE_CHECKING:
from mknodes.data import datatypes


logger = log.get_logger(__name__)

Expand Down
8 changes: 5 additions & 3 deletions mknodes/basenodes/mkbinaryimage/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
from __future__ import annotations

import os
import upath

from typing import Any, Literal, Self
from typing import Any, Literal, Self, TYPE_CHECKING

from jinjarope import textfilters

from mknodes.basenodes import mkimage
from mknodes.info import linkprovider
from mknodes.utils import icons, log

if TYPE_CHECKING:
from mknodes.info import linkprovider
import os


logger = log.get_logger(__name__)

Expand Down
6 changes: 4 additions & 2 deletions mknodes/basenodes/mkclidoc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from __future__ import annotations
import argparse

from typing import Any
from typing import Any, TYPE_CHECKING

from mknodes.templatenodes import mktemplate
from mknodes.utils import log
from mknodes.info.cli import clihelpers, commandinfo

if TYPE_CHECKING:
import argparse

logger = log.get_logger(__name__)


Expand Down
2 changes: 1 addition & 1 deletion mknodes/basenodes/mkcode/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import inspect
import os
import textwrap
import types

Expand All @@ -16,6 +15,7 @@


if TYPE_CHECKING:
import os
import mknodes as mk

logger = log.get_logger(__name__)
Expand Down
6 changes: 4 additions & 2 deletions mknodes/basenodes/mkcompactadmonition/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from __future__ import annotations

from typing import Any
from typing import Any, TYPE_CHECKING

from mknodes.basenodes import mknode
from mknodes.data import datatypes
from mknodes.utils import log, resources, xmlhelpers

if TYPE_CHECKING:
from mknodes.data import datatypes


logger = log.get_logger(__name__)

Expand Down
6 changes: 4 additions & 2 deletions mknodes/basenodes/mkcontainer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from __future__ import annotations

from collections.abc import Iterator

from typing import Any
from typing import Any, TYPE_CHECKING

from mknodes.basenodes import mknode
from mknodes.utils import log

if TYPE_CHECKING:
from collections.abc import Iterator


logger = log.get_logger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion mknodes/basenodes/mkdetailsblock/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from typing import TYPE_CHECKING, Any

from mknodes.basenodes import mkblock
from mknodes.data import datatypes
from mknodes.utils import log, reprhelpers, resources


if TYPE_CHECKING:
from mknodes.data import datatypes
import mknodes as mk


Expand Down
6 changes: 4 additions & 2 deletions mknodes/basenodes/mklist/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from __future__ import annotations

from collections.abc import Sequence
from typing import Any
from typing import Any, TYPE_CHECKING

from mknodes.basenodes import mkcontainer, mknode
from mknodes.info import linkprovider
from mknodes.utils import log, resources

if TYPE_CHECKING:
from collections.abc import Sequence


logger = log.get_logger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion mknodes/basenodes/mknode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from typing import TYPE_CHECKING, Any

from mknodes.basenodes import processors
from mknodes.data import datatypes
from mknodes.info import contexts, nodefile
from mknodes.jinja import nodeenvironment
from mknodes.nodemods.modmanager import ModManager
Expand All @@ -15,6 +14,7 @@


if TYPE_CHECKING:
from mknodes.data import datatypes
import mknodes as mk


Expand Down
7 changes: 5 additions & 2 deletions mknodes/basenodes/mktabcontainer.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from __future__ import annotations

from collections.abc import Mapping
from typing import Any
from typing import TYPE_CHECKING, Any

from mknodes.basenodes import mkcontainer, mknode, mktabs, mktext
from mknodes.utils import log, reprhelpers


if TYPE_CHECKING:
from collections.abc import Mapping


logger = log.get_logger(__name__)


Expand Down
7 changes: 5 additions & 2 deletions mknodes/data/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

import collections
from collections.abc import Callable, ItemsView, KeysView, ValuesView
from dataclasses import Field
import types
from types import MappingProxyType, SimpleNamespace
from typing import Any, ClassVar, Literal, Protocol, runtime_checkable
from typing import TYPE_CHECKING, Any, ClassVar, Literal, Protocol, runtime_checkable


if TYPE_CHECKING:
from dataclasses import Field


AdmonitionTypeStr = Literal[
Expand Down
6 changes: 5 additions & 1 deletion mknodes/data/fences.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from __future__ import annotations

from collections.abc import Callable
import dataclasses
from typing import TYPE_CHECKING

from pymdownx import superfences


if TYPE_CHECKING:
from collections.abc import Callable


@dataclasses.dataclass(frozen=True)
class Fences:
"""Class describing a superfence.
Expand Down
8 changes: 5 additions & 3 deletions mknodes/extranodes/mkcodeimage/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
from __future__ import annotations

import os
import textwrap

from typing import Any, Self
from typing import Any, Self, TYPE_CHECKING

from jinjarope import textfilters
import upath

from mknodes.basenodes import mknode
from mknodes.data import datatypes
from mknodes.utils import classhelpers, inspecthelpers, log, richhelpers

if TYPE_CHECKING:
from mknodes.data import datatypes
import os


logger = log.get_logger(__name__)

Expand Down
6 changes: 4 additions & 2 deletions mknodes/extranodes/mkprettyprint/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from __future__ import annotations

from typing import Any
from typing import Any, TYPE_CHECKING

from mknodes.templatenodes import mktemplate
from mknodes.data import datatypes
from mknodes.utils import log

if TYPE_CHECKING:
from mknodes.data import datatypes


logger = log.get_logger(__name__)

Expand Down
6 changes: 4 additions & 2 deletions mknodes/extranodes/mkseedir/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
from __future__ import annotations

import os
import upath

from typing import Any, Literal
from typing import Any, Literal, TYPE_CHECKING

from mknodes.basenodes import mkcode
from mknodes.utils import helpers, log, resources

if TYPE_CHECKING:
import os


logger = log.get_logger(__name__)

Expand Down
6 changes: 4 additions & 2 deletions mknodes/extranodes/mksnippet/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from __future__ import annotations

import os
from typing import Any
from typing import Any, TYPE_CHECKING

from mknodes.basenodes import mknode
from mknodes.utils import log, resources

if TYPE_CHECKING:
import os


logger = log.get_logger(__name__)

Expand Down
6 changes: 5 additions & 1 deletion mknodes/info/cli/commandinfo.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from __future__ import annotations

import dataclasses
from typing import TYPE_CHECKING

from mknodes.info.cli import param
from mknodes.utils import reprhelpers


if TYPE_CHECKING:
from mknodes.info.cli import param


@dataclasses.dataclass(frozen=True)
class CommandInfo:
name: str
Expand Down
3 changes: 2 additions & 1 deletion mknodes/info/cli/param.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from __future__ import annotations

from collections.abc import Callable
import dataclasses
from typing import TYPE_CHECKING, Any, Literal

from mknodes.utils import reprhelpers


if TYPE_CHECKING:
from collections.abc import Callable

from click import types as clicktypes


Expand Down
7 changes: 5 additions & 2 deletions mknodes/info/configfile.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from __future__ import annotations

import os
from typing import Any
from typing import TYPE_CHECKING, Any

import upath

from mknodes.utils import superdict


if TYPE_CHECKING:
import os


class ConfigFile(superdict.SuperDict):
def __init__(self, path: str | os.PathLike | None = None):
"""Constructor.
Expand Down
15 changes: 10 additions & 5 deletions mknodes/info/contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
import abc
from collections.abc import Mapping, MutableMapping
import dataclasses
import datetime
import pathlib
import types
from typing import Any
from typing import TYPE_CHECKING, Any

from griffe.dataclasses import Alias, Module
import jinjarope

import mknodes as mk
Expand All @@ -21,10 +18,18 @@
packageregistry,
pyproject,
)
from mknodes.info.cli import commandinfo
from mknodes.utils import log, superdict


if TYPE_CHECKING:
import datetime
import types

from griffe.dataclasses import Alias, Module

from mknodes.info.cli import commandinfo


logger = log.get_logger(__name__)

DEFAULT_LOADER = jinjarope.FileSystemLoader("docs")
Expand Down
Loading

0 comments on commit 7d0f0aa

Please sign in to comment.