Repository navigation
Add stubs for dockerfile-parse #9305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fad94a1
Add stubs for dockerfile-parse
pyhedgehog 9066bd0
make stubtest and pyright happy: use typing_extensions.Literal instea…
pyhedgehog ae0e66b
add types-six to requirements + use typing_extensions.TypedDict inste…
pyhedgehog 4fbbb71
requires = ["types-six"] to dockerfile-parse/METADATA.toml
pyhedgehog 1f3cf13
Implemented a lot of suggestions of @AlexWaygood.
pyhedgehog c925c34
Add stubs/dockerfile-parse/@tests/stubtest_allowlist.txt
pyhedgehog 134b5b0
Fix a few minor style issues
AlexWaygood File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 sys import version_info as version_info | ||
|
|
||
| PY2: bool | ||
|
AlexWaygood marked this conversation as resolved.
Resolved
|
||
| DOCKERFILE_FILENAME: str | ||
| COMMENT_INSTRUCTION: str | ||
This file contains hidden or 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,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 | ||
|
AlexWaygood marked this conversation as resolved.
Resolved
|
||
|
|
||
| class KeyValues(dict[str, str]): | ||
| parser_attr: str | None | ||
|
AlexWaygood marked this conversation as resolved.
Resolved
|
||
| parser: DockerfileParser | ||
| def __init__(self, key_values: dict[str, str], parser: DockerfileParser) -> None: ... | ||
|
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: ... | ||
|
AlexWaygood marked this conversation as resolved.
Resolved
|
||
| def __hash__(self) -> int: ... # type: ignore | ||
|
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 | ||
|
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] | ||
|
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 = ..., | ||
|
AlexWaygood marked this conversation as resolved.
Resolved
|
||
| fileobj: t.IO[str] | None = ..., | ||
| build_args: t.Mapping[str, str] | None = ..., | ||
|
AlexWaygood marked this conversation as resolved.
Resolved
|
||
| ) -> None: ... | ||
| @contextmanager | ||
| def _open_dockerfile(self, mode: str) -> t.Iterator[t.IO[str]]: ... | ||
|
AlexWaygood marked this conversation as resolved.
Resolved
|
||
| lines: t.Sequence[str] | ||
|
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 = ... | ||
|
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 = ... | ||
|
AlexWaygood marked this conversation as resolved.
Resolved
|
||
| ) -> None: ... | ||
| @property | ||
| def context_structure(self) -> list[str]: ... | ||
|
AlexWaygood marked this conversation as resolved.
Resolved
|
||
|
|
||
| def image_from(from_value: str) -> tuple[str, str | None]: ... | ||
|
AlexWaygood marked this conversation as resolved.
Resolved
|
||
This file contains hidden or 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,48 @@ | ||
| import typing as t | ||
| from collections.abc import Generator | ||
| from typing_extensions import Literal, TypeAlias | ||
|
|
||
| from .constants import PY2 as PY2 | ||
|
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 | ||
|
AlexWaygood marked this conversation as resolved.
Resolved
|
||
| stream: t.IO[str] | ||
|
AlexWaygood marked this conversation as resolved.
Resolved
|
||
| args: t.Mapping[str, str] | ||
| envs: t.Mapping[str, str] | ||
|
AlexWaygood marked this conversation as resolved.
Resolved
|
||
| quotes: _Quotes | ||
|
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 = ..., | ||
|
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]: ... | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.