| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,7 +34,7 @@ | |||
| 34 | 34 | from typing import (Any, Callable, IO, List, Dict, Sequence, | |
| 35 | 35 | TYPE_CHECKING, Tuple, Union, cast, overload) | |
| 36 | 36 | ||
| 37 | - from git.types import Lit_config_levels, ConfigLevels_Tup, PathLike, TBD, assert_never, is_config_level | ||
| 37 | + from git.types import Lit_config_levels, ConfigLevels_Tup, PathLike, TBD, assert_never | ||
| 38 | 38 | ||
| 39 | 39 | if TYPE_CHECKING: | |
| 40 | 40 | from git.repo.base import Repo | |
@@ -309,9 +309,9 @@ def __init__(self, file_or_files: Union[None, PathLike, 'BytesIO', Sequence[Unio | |||
| 309 | 309 | else: | |
| 310 | 310 | if config_level is None: | |
| 311 | 311 | if read_only: | |
| 312 | - self._file_or_files = [get_config_path(f) | ||
| 312 | + self._file_or_files = [get_config_path(cast(Lit_config_levels, f)) | ||
| 313 | 313 | for f in CONFIG_LEVELS | |
| 314 | - if is_config_level(f) and f != 'repository'] | ||
| 314 | + if f != 'repository'] | ||
| 315 | 315 | else: | |
| 316 | 316 | raise ValueError("No configuration level or configuration files specified") | |
| 317 | 317 | else: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,8 +15,8 @@ | |||
| 15 | 15 | ||
| 16 | 16 | # typing ------------------------------------------------------------------ | |
| 17 | 17 | ||
| 18 | - from typing import Any, Iterator, List, Match, Optional, Tuple, Type, TypeVar, Union, TYPE_CHECKING | ||
| 19 | - from git.types import PathLike, TBD, Literal, TypeGuard | ||
| 18 | + from typing import Any, Iterator, List, Match, Optional, Tuple, Type, TypeVar, Union, TYPE_CHECKING, cast | ||
| 19 | + from git.types import PathLike, TBD, Literal | ||
| 20 | 20 | ||
| 21 | 21 | if TYPE_CHECKING: | |
| 22 | 22 | from .objects.tree import Tree | |
@@ -28,9 +28,9 @@ | |||
| 28 | 28 | Lit_change_type = Literal['A', 'D', 'C', 'M', 'R', 'T', 'U'] | |
| 29 | 29 | ||
| 30 | 30 | ||
| 31 | - def is_change_type(inp: str) -> TypeGuard[Lit_change_type]: | ||
| 32 | - # return True | ||
| 33 | - return inp in ['A', 'D', 'C', 'M', 'R', 'T', 'U'] | ||
| 31 | + # def is_change_type(inp: str) -> TypeGuard[Lit_change_type]: | ||
| 32 | + # # return True | ||
| 33 | + # return inp in ['A', 'D', 'C', 'M', 'R', 'T', 'U'] | ||
| 34 | 34 | ||
| 35 | 35 | # ------------------------------------------------------------------------ | |
| 36 | 36 | ||
@@ -517,8 +517,8 @@ def _handle_diff_line(lines_bytes: bytes, repo: 'Repo', index: DiffIndex) -> Non | |||
| 517 | 517 | # Change type can be R100 | |
| 518 | 518 | # R: status letter | |
| 519 | 519 | # 100: score (in case of copy and rename) | |
| 520 | - assert is_change_type(_change_type[0]), f"Unexpected value for change_type received: {_change_type[0]}" | ||
| 521 | - change_type: Lit_change_type = _change_type[0] | ||
| 520 | + # assert is_change_type(_change_type[0]), f"Unexpected value for change_type received: {_change_type[0]}" | ||
| 521 | + change_type: Lit_change_type = cast(Lit_change_type, _change_type[0]) | ||
| 522 | 522 | score_str = ''.join(_change_type[1:]) | |
| 523 | 523 | score = int(score_str) if score_str.isdigit() else None | |
| 524 | 524 | path = path.strip() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -53,7 +53,7 @@ | |||
| 53 | 53 | ||
| 54 | 54 | from typing import (Dict, IO, List, Sequence, TYPE_CHECKING, Tuple, Type, Union, cast) | |
| 55 | 55 | ||
| 56 | - from git.types import PathLike, TypeGuard | ||
| 56 | + from git.types import PathLike | ||
| 57 | 57 | ||
| 58 | 58 | if TYPE_CHECKING: | |
| 59 | 59 | from .base import IndexFile | |
@@ -188,15 +188,16 @@ def entry_key(*entry: Union[BaseIndexEntry, PathLike, int]) -> Tuple[PathLike, i | |||
| 188 | 188 | """:return: Key suitable to be used for the index.entries dictionary | |
| 189 | 189 | :param entry: One instance of type BaseIndexEntry or the path and the stage""" | |
| 190 | 190 | ||
| 191 | - def is_entry_key_tup(entry_key: Tuple) -> TypeGuard[Tuple[PathLike, int]]: | ||
| 192 | - return isinstance(entry_key, tuple) and len(entry_key) == 2 | ||
| 191 | + # def is_entry_key_tup(entry_key: Tuple) -> TypeGuard[Tuple[PathLike, int]]: | ||
| 192 | + # return isinstance(entry_key, tuple) and len(entry_key) == 2 | ||
| 193 | 193 | ||
| 194 | 194 | if len(entry) == 1: | |
| 195 | 195 | entry_first = entry[0] | |
| 196 | 196 | assert isinstance(entry_first, BaseIndexEntry) | |
| 197 | 197 | return (entry_first.path, entry_first.stage) | |
| 198 | 198 | else: | |
| 199 | - assert is_entry_key_tup(entry) | ||
| 199 | + # assert is_entry_key_tup(entry) | ||
| 200 | + entry = cast(Tuple[PathLike, int], entry) | ||
| 200 | 201 | return entry | |
| 201 | 202 | # END handle entry | |
| 202 | 203 | ||
@@ -244,7 +245,7 @@ def read_cache(stream: IO[bytes]) -> Tuple[int, Dict[Tuple[PathLike, int], 'Inde | |||
| 244 | 245 | content_sha = extension_data[-20:] | |
| 245 | 246 | ||
| 246 | 247 | # truncate the sha in the end as we will dynamically create it anyway | |
| 247 | - extension_data = extension_data[:-20] | ||
| 248 | + extension_data = extension_data[: -20] | ||
| 248 | 249 | ||
| 249 | 250 | return (version, entries, extension_data, content_sha) | |
| 250 | 251 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,9 +39,9 @@ | |||
| 39 | 39 | ||
| 40 | 40 | # typing ------------------------------------------------------------------ | |
| 41 | 41 | ||
| 42 | - from typing import Any, IO, Iterator, List, Sequence, Tuple, Union, TYPE_CHECKING | ||
| 42 | + from typing import Any, IO, Iterator, List, Sequence, Tuple, Union, TYPE_CHECKING, cast | ||
| 43 | 43 | ||
| 44 | - from git.types import PathLike, TypeGuard, Literal | ||
| 44 | + from git.types import PathLike, Literal | ||
| 45 | 45 | ||
| 46 | 46 | if TYPE_CHECKING: | |
| 47 | 47 | from git.repo import Repo | |
@@ -323,16 +323,18 @@ def _iter_from_process_or_stream(cls, repo: 'Repo', proc_or_stream: Union[Popen, | |||
| 323 | 323 | :param proc: git-rev-list process instance - one sha per line | |
| 324 | 324 | :return: iterator returning Commit objects""" | |
| 325 | 325 | ||
| 326 | - def is_proc(inp) -> TypeGuard[Popen]: | ||
| 327 | - return hasattr(proc_or_stream, 'wait') and not hasattr(proc_or_stream, 'readline') | ||
| 326 | + # def is_proc(inp) -> TypeGuard[Popen]: | ||
| 327 | + # return hasattr(proc_or_stream, 'wait') and not hasattr(proc_or_stream, 'readline') | ||
| 328 | 328 | ||
| 329 | - def is_stream(inp) -> TypeGuard[IO]: | ||
| 330 | - return hasattr(proc_or_stream, 'readline') | ||
| 329 | + # def is_stream(inp) -> TypeGuard[IO]: | ||
| 330 | + # return hasattr(proc_or_stream, 'readline') | ||
| 331 | 331 | ||
| 332 | - if is_proc(proc_or_stream): | ||
| 332 | + if hasattr(proc_or_stream, 'wait'): | ||
| 333 | + proc_or_stream = cast(Popen, proc_or_stream) | ||
| 333 | 334 | if proc_or_stream.stdout is not None: | |
| 334 | 335 | stream = proc_or_stream.stdout | |
| 335 | - elif is_stream(proc_or_stream): | ||
| 336 | + elif hasattr(proc_or_stream, 'readline'): | ||
| 337 | + proc_or_stream = cast(IO, proc_or_stream) | ||
| 336 | 338 | stream = proc_or_stream | |
| 337 | 339 | ||
| 338 | 340 | readline = stream.readline | |
@@ -351,7 +353,8 @@ def is_stream(inp) -> TypeGuard[IO]: | |||
| 351 | 353 | # END for each line in stream | |
| 352 | 354 | # TODO: Review this - it seems process handling got a bit out of control | |
| 353 | 355 | # due to many developers trying to fix the open file handles issue | |
| 354 | - if is_proc(proc_or_stream): | ||
| 356 | + if hasattr(proc_or_stream, 'wait'): | ||
| 357 | + proc_or_stream = cast(Popen, proc_or_stream) | ||
| 355 | 358 | finalize_process(proc_or_stream) | |
| 356 | 359 | ||
| 357 | 360 | @ classmethod | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,7 +24,7 @@ | |||
| 24 | 24 | from typing import (Any, Callable, Dict, Iterable, Iterator, List, | |
| 25 | 25 | Tuple, Type, Union, cast, TYPE_CHECKING) | |
| 26 | 26 | ||
| 27 | - from git.types import PathLike, TypeGuard, Literal | ||
| 27 | + from git.types import PathLike, Literal | ||
| 28 | 28 | ||
| 29 | 29 | if TYPE_CHECKING: | |
| 30 | 30 | from git.repo import Repo | |
@@ -36,8 +36,8 @@ | |||
| 36 | 36 | Tuple['Submodule', 'Submodule']]] | |
| 37 | 37 | ||
| 38 | 38 | ||
| 39 | - def is_tree_cache(inp: Tuple[bytes, int, str]) -> TypeGuard[TreeCacheTup]: | ||
| 40 | - return isinstance(inp[0], bytes) and isinstance(inp[1], int) and isinstance([inp], str) | ||
| 39 | + # def is_tree_cache(inp: Tuple[bytes, int, str]) -> TypeGuard[TreeCacheTup]: | ||
| 40 | + # return isinstance(inp[0], bytes) and isinstance(inp[1], int) and isinstance([inp], str) | ||
| 41 | 41 | ||
| 42 | 42 | #-------------------------------------------------------- | |
| 43 | 43 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,7 +8,7 @@ | |||
| 8 | 8 | # typing ------------------------------------------------------------------ | |
| 9 | 9 | ||
| 10 | 10 | from typing import Any, Callable, Iterator, List, Match, Optional, Tuple, Type, TypeVar, Union, TYPE_CHECKING # NOQA | |
| 11 | - from git.types import Commit_ish, PathLike, TBD, Literal, TypeGuard, _T # NOQA | ||
| 11 | + from git.types import Commit_ish, PathLike, TBD, Literal, _T # NOQA | ||
| 12 | 12 | ||
| 13 | 13 | if TYPE_CHECKING: | |
| 14 | 14 | from git.repo import Repo | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,7 +24,7 @@ | |||
| 24 | 24 | # typing ------------------------------------------------------------------ | |
| 25 | 25 | ||
| 26 | 26 | from typing import Any, Iterator, List, Match, Optional, Tuple, Type, TypeVar, Union, TYPE_CHECKING # NOQA | |
| 27 | - from git.types import Commit_ish, PathLike, TBD, Literal, TypeGuard # NOQA | ||
| 27 | + from git.types import Commit_ish, PathLike, TBD, Literal # NOQA | ||
| 28 | 28 | ||
| 29 | 29 | if TYPE_CHECKING: | |
| 30 | 30 | from git.repo import Repo | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,9 +37,9 @@ | |||
| 37 | 37 | # typing------------------------------------------------------- | |
| 38 | 38 | ||
| 39 | 39 | from typing import (Any, Callable, Dict, Iterator, List, NoReturn, Optional, Sequence, # NOQA[TC002] | |
| 40 | - TYPE_CHECKING, Type, Union, overload) | ||
| 40 | + TYPE_CHECKING, Type, Union, cast, overload) | ||
| 41 | 41 | ||
| 42 | - from git.types import PathLike, Literal, TBD, TypeGuard, Commit_ish # NOQA[TC002] | ||
| 42 | + from git.types import PathLike, Literal, TBD, Commit_ish # NOQA[TC002] | ||
| 43 | 43 | ||
| 44 | 44 | if TYPE_CHECKING: | |
| 45 | 45 | from git.repo.base import Repo | |
@@ -50,8 +50,8 @@ | |||
| 50 | 50 | flagKeyLiteral = Literal[' ', '!', '+', '-', '*', '=', 't', '?'] | |
| 51 | 51 | ||
| 52 | 52 | ||
| 53 | - def is_flagKeyLiteral(inp: str) -> TypeGuard[flagKeyLiteral]: | ||
| 54 | - return inp in [' ', '!', '+', '-', '=', '*', 't', '?'] | ||
| 53 | + # def is_flagKeyLiteral(inp: str) -> TypeGuard[flagKeyLiteral]: | ||
| 54 | + # return inp in [' ', '!', '+', '-', '=', '*', 't', '?'] | ||
| 55 | 55 | ||
| 56 | 56 | ||
| 57 | 57 | # ------------------------------------------------------------- | |
@@ -342,8 +342,8 @@ def _from_line(cls, repo: 'Repo', line: str, fetch_line: str) -> 'FetchInfo': | |||
| 342 | 342 | # parse lines | |
| 343 | 343 | remote_local_ref_str: str | |
| 344 | 344 | control_character, operation, local_remote_ref, remote_local_ref_str, note = match.groups() | |
| 345 | - assert is_flagKeyLiteral(control_character), f"{control_character}" | ||
| 346 | - | ||
| 345 | + # assert is_flagKeyLiteral(control_character), f"{control_character}" | ||
| 346 | + control_character = cast(flagKeyLiteral, control_character) | ||
| 347 | 347 | try: | |
| 348 | 348 | _new_hex_sha, _fetch_operation, fetch_note = fetch_line.split("\t") | |
| 349 | 349 | ref_type_name, fetch_note = fetch_note.split(' ', 1) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,7 +36,7 @@ | |||
| 36 | 36 | ||
| 37 | 37 | # typing ------------------------------------------------------ | |
| 38 | 38 | ||
| 39 | - from git.types import TBD, PathLike, Lit_config_levels, Commit_ish, Tree_ish, is_config_level | ||
| 39 | + from git.types import TBD, PathLike, Lit_config_levels, Commit_ish, Tree_ish | ||
| 40 | 40 | from typing import (Any, BinaryIO, Callable, Dict, | |
| 41 | 41 | Iterator, List, Mapping, Optional, Sequence, | |
| 42 | 42 | TextIO, Tuple, Type, Union, | |
@@ -498,7 +498,8 @@ def config_reader(self, config_level: Optional[Lit_config_levels] = None) -> Git | |||
| 498 | 498 | unknown, instead the global path will be used.""" | |
| 499 | 499 | files = None | |
| 500 | 500 | if config_level is None: | |
| 501 | - files = [self._get_config_path(f) for f in self.config_level if is_config_level(f)] | ||
| 501 | + files = [self._get_config_path(cast(Lit_config_levels, f)) | ||
| 502 | + for f in self.config_level if cast(Lit_config_levels, f)] | ||
| 502 | 503 | else: | |
| 503 | 504 | files = [self._get_config_path(config_level)] | |
| 504 | 505 | return GitConfigParser(files, read_only=True, repo=self) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,10 +12,10 @@ | |||
| 12 | 12 | else: | |
| 13 | 13 | from typing_extensions import Final, Literal, SupportsIndex, TypedDict, Protocol, runtime_checkable # noqa: F401 | |
| 14 | 14 | ||
| 15 | - if sys.version_info[:2] >= (3, 10): | ||
| 16 | - from typing import TypeGuard # noqa: F401 | ||
| 17 | - else: | ||
| 18 | - from typing_extensions import TypeGuard # noqa: F401 | ||
| 15 | + # if sys.version_info[:2] >= (3, 10): | ||
| 16 | + # from typing import TypeGuard # noqa: F401 | ||
| 17 | + # else: | ||
| 18 | + # from typing_extensions import TypeGuard # noqa: F401 | ||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | 21 | if sys.version_info[:2] < (3, 9): | |
@@ -41,9 +41,9 @@ | |||
| 41 | 41 | Lit_config_levels = Literal['system', 'global', 'user', 'repository'] | |
| 42 | 42 | ||
| 43 | 43 | ||
| 44 | - def is_config_level(inp: str) -> TypeGuard[Lit_config_levels]: | ||
| 45 | - # return inp in get_args(Lit_config_level) # only py >= 3.8 | ||
| 46 | - return inp in ("system", "user", "global", "repository") | ||
| 44 | + # def is_config_level(inp: str) -> TypeGuard[Lit_config_levels]: | ||
| 45 | + # # return inp in get_args(Lit_config_level) # only py >= 3.8 | ||
| 46 | + # return inp in ("system", "user", "global", "repository") | ||
| 47 | 47 | ||
| 48 | 48 | ||
| 49 | 49 | ConfigLevels_Tup = Tuple[Literal['system'], Literal['user'], Literal['global'], Literal['repository']] | |
| Back | FazBrowse Home | New Git URL |
0 commit comments