Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"stubs/commonmark",
"stubs/cryptography",
"stubs/dateparser",
"stubs/dockerfile-parse",
"stubs/docutils",
"stubs/Flask-Migrate",
"stubs/Flask-SQLAlchemy",
Expand Down
5 changes: 5 additions & 0 deletions stubs/dockerfile-parse/METADATA.toml
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
3 changes: 3 additions & 0 deletions stubs/dockerfile-parse/dockerfile_parse/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .parser import DockerfileParser as DockerfileParser

__version__: str
5 changes: 5 additions & 0 deletions stubs/dockerfile-parse/dockerfile_parse/constants.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from sys import version_info as version_info
Comment thread
AlexWaygood marked this conversation as resolved.
Resolved

PY2: bool
Comment thread
AlexWaygood marked this conversation as resolved.
Resolved
DOCKERFILE_FILENAME: str
COMMENT_INSTRUCTION: str
79 changes: 79 additions & 0 deletions stubs/dockerfile-parse/dockerfile_parse/parser.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import logging
import typing as t
from contextlib import contextmanager
from typing_extensions import TypedDict

from six import string_types as string_types

from .constants import COMMENT_INSTRUCTION as COMMENT_INSTRUCTION, DOCKERFILE_FILENAME as DOCKERFILE_FILENAME

logger: logging.Logger
Comment thread
AlexWaygood marked this conversation as resolved.
Resolved

class KeyValues(dict[str, str]):
parser_attr: str | None
Comment thread
AlexWaygood marked this conversation as resolved.
Resolved
parser: DockerfileParser
def __init__(self, key_values: dict[str, str], parser: DockerfileParser) -> None: ...
Comment thread
AlexWaygood marked this conversation as resolved.
Resolved
def __delitem__(self, key: str) -> None: ...
def __setitem__(self, key: str, value: str) -> None: ...
def __eq__(self, other) -> bool: ...
Comment thread
AlexWaygood marked this conversation as resolved.
Resolved
def __hash__(self) -> int: ... # type: ignore
Comment thread
AlexWaygood marked this conversation as resolved.
Resolved

class Labels(KeyValues):
parser_attr: str

class Envs(KeyValues):
parser_attr: str

class Args(KeyValues):
parser_attr: str

class _InstructionDict(TypedDict):
instruction: str
startline: int
endline: int
content: str
value: str

class DockerfileParser:
fileobj: t.IO[str]
dockerfile_path: str | None
Comment thread
AlexWaygood marked this conversation as resolved.
Resolved
cache_content: bool
cached_content: str
env_replace: bool
parent_env: t.Mapping[str, str]
build_args: t.Mapping[str, str]
Comment thread
AlexWaygood marked this conversation as resolved.
Resolved
def __init__(
self,
path: str | None = ...,
cache_content: bool = ...,
env_replace: bool = ...,
parent_env: t.Mapping[str, str] | None = ...,
Comment thread
AlexWaygood marked this conversation as resolved.
Resolved
fileobj: t.IO[str] | None = ...,
build_args: t.Mapping[str, str] | None = ...,
Comment thread
AlexWaygood marked this conversation as resolved.
Resolved
) -> None: ...
@contextmanager
def _open_dockerfile(self, mode: str) -> t.Iterator[t.IO[str]]: ...
Comment thread
AlexWaygood marked this conversation as resolved.
Resolved
lines: t.Sequence[str]
Comment thread
AlexWaygood marked this conversation as resolved.
Resolved
content: str
@property
def structure(self) -> list[_InstructionDict]: ...
@property
def json(self) -> str: ...
parent_images: t.Sequence[str]
@property
def is_multistage(self) -> bool: ...
baseimage: str
cmd: str
labels: t.Mapping[str, str]
envs: t.Mapping[str, str]
args: t.Mapping[str, str]
def add_lines(
self, *lines: list[str], all_stages: bool | None = ..., at_start: bool | None = ..., skip_scratch: bool | None = ...
Comment thread
AlexWaygood marked this conversation as resolved.
Resolved
) -> None: ...
def add_lines_at(
self, anchor: str | int | dict[str, int], *lines: list[str], replace: bool | None = ..., after: bool | None = ...
Comment thread
AlexWaygood marked this conversation as resolved.
Resolved
) -> None: ...
@property
def context_structure(self) -> list[str]: ...
Comment thread
AlexWaygood marked this conversation as resolved.
Resolved

def image_from(from_value: str) -> tuple[str, str | None]: ...
Comment thread
AlexWaygood marked this conversation as resolved.
Resolved
48 changes: 48 additions & 0 deletions stubs/dockerfile-parse/dockerfile_parse/util.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import typing as t
from collections.abc import Generator
from typing_extensions import Literal, TypeAlias

from .constants import PY2 as PY2
Comment thread
AlexWaygood marked this conversation as resolved.
Resolved

def b2u(string: bytes | str) -> str: ...
def u2b(string: str | bytes) -> bytes: ...

_Quotes: TypeAlias = Literal["'", '"']
_ContextType: TypeAlias = Literal["ARG", "ENV", "LABEL"]

class WordSplitter:
SQUOTE: _Quotes
DQUOTE: _Quotes
Comment thread
AlexWaygood marked this conversation as resolved.
Resolved
stream: t.IO[str]
Comment thread
AlexWaygood marked this conversation as resolved.
Resolved
args: t.Mapping[str, str]
envs: t.Mapping[str, str]
Comment thread
AlexWaygood marked this conversation as resolved.
Resolved
quotes: _Quotes
Comment thread
AlexWaygood marked this conversation as resolved.
Resolved
escaped: bool
def __init__(self, s: str, args: t.Mapping[str, str] | None = ..., envs: t.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: t.Mapping[str, str], envs: t.Mapping[str, str], instruction_value: str): ...
def get_key_val_dictionary(
instruction_value, env_replace: bool = ..., args: t.Mapping[str, str] | None = ..., envs: t.Mapping[str, str] | None = ...
): ...

class Context:
args: t.Mapping[str, str]
envs: t.Mapping[str, str]
labels: t.Mapping[str, str]
line_args: t.Mapping[str, str]
line_envs: t.Mapping[str, str]
line_labels: t.Mapping[str, str]
def __init__(
self,
args: t.Mapping[str, str] | None = ...,
envs: t.Mapping[str, str] | None = ...,
labels: t.Mapping[str, str] | None = ...,
Comment thread
AlexWaygood marked this conversation as resolved.
Resolved
line_args: t.Mapping[str, str] | None = ...,
line_envs: t.Mapping[str, str] | None = ...,
line_labels: t.Mapping[str, str] | None = ...,
) -> None: ...
def set_line_value(self, context_type: _ContextType, value: t.Mapping[str, str]) -> None: ...
def get_line_value(self, context_type: _ContextType) -> t.Mapping[str, str]: ...
def get_values(self, context_type: _ContextType) -> t.Mapping[str, str]: ...