-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add stubs for dockerfile-parse (#9305)
Co-authored-by: AlexWaygood <[email protected]>
- Loading branch information
1 parent
ee69f60
commit 87d2683
Showing
7 changed files
with
134 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
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,5 @@ | ||
version = "1.2.*" | ||
requires = ["types-six"] | ||
|
||
[tool.stubtest] | ||
ignore_missing_stub = false |
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 @@ | ||
from .parser import DockerfileParser as DockerfileParser | ||
|
||
__version__: str |
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,5 @@ | ||
from typing_extensions import Literal | ||
|
||
PY2: Literal[False] | ||
DOCKERFILE_FILENAME: str | ||
COMMENT_INSTRUCTION: str |
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,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]: ... |
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,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]: ... |