mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 04:34:28 +08:00
Add stubs for dockerfile-parse (#9305)
Co-authored-by: AlexWaygood <alex.waygood@gmail.com>
This commit is contained in:
6
stubs/dockerfile-parse/@tests/stubtest_allowlist.txt
Normal file
6
stubs/dockerfile-parse/@tests/stubtest_allowlist.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
# These are re-exports which we consider an implementation detail
|
||||
dockerfile_parse.constants.version_info
|
||||
dockerfile_parse.parser.string_types
|
||||
dockerfile_parse.parser.DOCKERFILE_FILENAME
|
||||
dockerfile_parse.parser.COMMENT_INSTRUCTION
|
||||
dockerfile_parse.util.PY2
|
||||
5
stubs/dockerfile-parse/METADATA.toml
Normal file
5
stubs/dockerfile-parse/METADATA.toml
Normal file
@@ -0,0 +1,5 @@
|
||||
version = "1.2.*"
|
||||
requires = ["types-six"]
|
||||
|
||||
[tool.stubtest]
|
||||
ignore_missing_stub = false
|
||||
3
stubs/dockerfile-parse/dockerfile_parse/__init__.pyi
Normal file
3
stubs/dockerfile-parse/dockerfile_parse/__init__.pyi
Normal file
@@ -0,0 +1,3 @@
|
||||
from .parser import DockerfileParser as DockerfileParser
|
||||
|
||||
__version__: str
|
||||
5
stubs/dockerfile-parse/dockerfile_parse/constants.pyi
Normal file
5
stubs/dockerfile-parse/dockerfile_parse/constants.pyi
Normal file
@@ -0,0 +1,5 @@
|
||||
from typing_extensions import Literal
|
||||
|
||||
PY2: Literal[False]
|
||||
DOCKERFILE_FILENAME: str
|
||||
COMMENT_INSTRUCTION: str
|
||||
67
stubs/dockerfile-parse/dockerfile_parse/parser.pyi
Normal file
67
stubs/dockerfile-parse/dockerfile_parse/parser.pyi
Normal file
@@ -0,0 +1,67 @@
|
||||
from collections.abc import Mapping, Sequence
|
||||
from typing import IO, ClassVar
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
from .util import Context
|
||||
|
||||
class KeyValues(dict[str, str]):
|
||||
parser_attr: ClassVar[str | None]
|
||||
parser: DockerfileParser
|
||||
def __init__(self, key_values: Mapping[str, str], parser: DockerfileParser) -> None: ...
|
||||
def __delitem__(self, key: str) -> None: ...
|
||||
def __setitem__(self, key: str, value: str) -> None: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
def __hash__(self) -> int: ... # type: ignore[override]
|
||||
|
||||
class Labels(KeyValues): ...
|
||||
class Envs(KeyValues): ...
|
||||
class Args(KeyValues): ...
|
||||
|
||||
class _InstructionDict(TypedDict):
|
||||
instruction: str
|
||||
startline: int
|
||||
endline: int
|
||||
content: str
|
||||
value: str
|
||||
|
||||
class DockerfileParser:
|
||||
fileobj: IO[str]
|
||||
dockerfile_path: str
|
||||
cache_content: bool
|
||||
cached_content: str
|
||||
env_replace: bool
|
||||
parent_env: dict[str, str]
|
||||
build_args: dict[str, str]
|
||||
def __init__(
|
||||
self,
|
||||
path: str | None = ...,
|
||||
cache_content: bool = ...,
|
||||
env_replace: bool = ...,
|
||||
parent_env: dict[str, str] | None = ...,
|
||||
fileobj: IO[str] | None = ...,
|
||||
build_args: dict[str, str] | None = ...,
|
||||
) -> None: ...
|
||||
lines: list[str]
|
||||
content: str
|
||||
@property
|
||||
def structure(self) -> list[_InstructionDict]: ...
|
||||
@property
|
||||
def json(self) -> str: ...
|
||||
parent_images: Sequence[str]
|
||||
@property
|
||||
def is_multistage(self) -> bool: ...
|
||||
baseimage: str
|
||||
cmd: str
|
||||
labels: Mapping[str, str]
|
||||
envs: Mapping[str, str]
|
||||
args: Mapping[str, str]
|
||||
def add_lines(
|
||||
self, *lines: str, all_stages: bool | None = ..., at_start: bool | None = ..., skip_scratch: bool | None = ...
|
||||
) -> None: ...
|
||||
def add_lines_at(
|
||||
self, anchor: str | int | dict[str, int], *lines: str, replace: bool | None = ..., after: bool | None = ...
|
||||
) -> None: ...
|
||||
@property
|
||||
def context_structure(self) -> list[Context]: ...
|
||||
|
||||
def image_from(from_value: str) -> tuple[str | None, str | None]: ...
|
||||
47
stubs/dockerfile-parse/dockerfile_parse/util.pyi
Normal file
47
stubs/dockerfile-parse/dockerfile_parse/util.pyi
Normal file
@@ -0,0 +1,47 @@
|
||||
from collections.abc import Generator, Mapping, MutableMapping
|
||||
from io import StringIO
|
||||
from typing import ClassVar
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
def b2u(string: bytes | str) -> str: ...
|
||||
def u2b(string: str | bytes) -> bytes: ...
|
||||
|
||||
_Quotes: TypeAlias = Literal["'", '"']
|
||||
_ContextType: TypeAlias = Literal["ARG", "ENV", "LABEL"]
|
||||
|
||||
class WordSplitter:
|
||||
SQUOTE: ClassVar[_Quotes]
|
||||
DQUOTE: ClassVar[_Quotes]
|
||||
stream: StringIO
|
||||
args: Mapping[str, str] | None
|
||||
envs: Mapping[str, str] | None
|
||||
quotes: _Quotes | None
|
||||
escaped: bool
|
||||
def __init__(self, s: str, args: Mapping[str, str] | None = ..., envs: Mapping[str, str] | None = ...) -> None: ...
|
||||
def dequote(self) -> str: ...
|
||||
def split(self, maxsplit: int | None = ..., dequote: bool = ...) -> Generator[str | None, None, None]: ...
|
||||
|
||||
def extract_key_values(env_replace: bool, args: Mapping[str, str], envs: Mapping[str, str], instruction_value: str): ...
|
||||
def get_key_val_dictionary(
|
||||
instruction_value, env_replace: bool = ..., args: Mapping[str, str] | None = ..., envs: Mapping[str, str] | None = ...
|
||||
): ...
|
||||
|
||||
class Context:
|
||||
args: MutableMapping[str, str]
|
||||
envs: MutableMapping[str, str]
|
||||
labels: MutableMapping[str, str]
|
||||
line_args: Mapping[str, str]
|
||||
line_envs: Mapping[str, str]
|
||||
line_labels: Mapping[str, str]
|
||||
def __init__(
|
||||
self,
|
||||
args: MutableMapping[str, str] | None = ...,
|
||||
envs: MutableMapping[str, str] | None = ...,
|
||||
labels: MutableMapping[str, str] | None = ...,
|
||||
line_args: Mapping[str, str] | None = ...,
|
||||
line_envs: Mapping[str, str] | None = ...,
|
||||
line_labels: Mapping[str, str] | None = ...,
|
||||
) -> None: ...
|
||||
def set_line_value(self, context_type: _ContextType, value: Mapping[str, str]) -> None: ...
|
||||
def get_line_value(self, context_type: _ContextType) -> Mapping[str, str]: ...
|
||||
def get_values(self, context_type: _ContextType) -> Mapping[str, str]: ...
|
||||
Reference in New Issue
Block a user