Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Finish typing object, improve verious other types.#1279

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Byron merged 28 commits intogitpython-developers:mainfromYobmod:main
Jun 26, 2021
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
28 commits
Select commitHold shift + click to select a range
5b6fe83
Update typing-extensions version in requirements.txt
YobmodJun 23, 2021
00b5802
Merge branch 'gitpython-developers:main' into main
YobmodJun 23, 2021
6500844
Merge branch 'gitpython-developers:main' into main
YobmodJun 24, 2021
42e4f5e
Add types to tree.Tree
YobmodJun 24, 2021
c3903d8
Make IterableList generic and update throughout
YobmodJun 24, 2021
3cef949
Rename Iterable due to typing.Iterable. Add deprecation warning
YobmodJun 24, 2021
ae9d56e
Make Iterable deprecation warning on subclassing
YobmodJun 24, 2021
8bf00a6
fix an import
YobmodJun 24, 2021
26dfeb6
fix indent
YobmodJun 24, 2021
4f5d2fd
update docstring
YobmodJun 24, 2021
d9f9027
update some TBDs to configparser
YobmodJun 24, 2021
affee35
Add typedDict
YobmodJun 24, 2021
fe594eb
Add T_Tre_cache TypeVar
YobmodJun 24, 2021
59c8944
forward ref Gitconfigparser
YobmodJun 24, 2021
b72118e
Import TypeGuard to replace casts
YobmodJun 24, 2021
fb3fec3
Update typing-extensions dependancy to <py3.10 for typeguard
YobmodJun 24, 2021
a2d9011
Add asserts and casts for T_Tree_cache
YobmodJun 24, 2021
0eae33d
Add is_flatLiteral() Typeguard[] to remote.py
YobmodJun 25, 2021
5b0465c
fix assert
YobmodJun 25, 2021
dc8d23d
Add '?' to controlcharacter literal
YobmodJun 25, 2021
7b09003
replace cast()s with asserts in remote.py
YobmodJun 25, 2021
aba4d9b
replace cast()s with asserts in fun.py
YobmodJun 25, 2021
07bfe1a
trigger checks to rurun
YobmodJun 25, 2021
09fb227
Add type to submodule to trigger checks to rurun
YobmodJun 25, 2021
eff48b8
Import typevar in util.py
YobmodJun 25, 2021
17c750a
flake8 fix
YobmodJun 25, 2021
ff56dbb
fix typo
YobmodJun 25, 2021
5d7b8ba
another typo
YobmodJun 25, 2021
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
2 changes: 1 addition & 1 deletiongit/index/base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -568,7 +568,7 @@ def write_tree(self) -> Tree:
# note: additional deserialization could be saved if write_tree_from_cache
# would return sorted tree entries
root_tree = Tree(self.repo, binsha, path='')
root_tree._cache = tree_items
root_tree._cache = tree_items # type: ignore
return root_tree

def _process_diff_args(self, args: List[Union[str, diff.Diffable, object]]
Expand Down
14 changes: 10 additions & 4 deletionsgit/index/fun.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -53,7 +53,7 @@

from typing import (Dict, IO, List, Sequence, TYPE_CHECKING, Tuple, Type, Union, cast)

from git.types import PathLike
from git.types import PathLike, TypeGuard

if TYPE_CHECKING:
from .base import IndexFile
Expand DownExpand Up@@ -185,11 +185,17 @@ def read_header(stream: IO[bytes]) -> Tuple[int, int]:
def entry_key(*entry: Union[BaseIndexEntry, PathLike, int]) -> Tuple[PathLike, int]:
""":return: Key suitable to be used for the index.entries dictionary
:param entry: One instance of type BaseIndexEntry or the path and the stage"""

def is_entry_tuple(entry: Tuple) -> TypeGuard[Tuple[PathLike, int]]:
return isinstance(entry, tuple) and len(entry) == 2

if len(entry) == 1:
entry_first = cast(BaseIndexEntry, entry[0]) # type: BaseIndexEntry
entry_first = entry[0]
assert isinstance(entry_first, BaseIndexEntry)
return (entry_first.path, entry_first.stage)
else:
entry = cast(Tuple[PathLike, int], tuple(entry))
# entry = tuple(entry)
assert is_entry_tuple(entry)
return entry
# END handle entry

Expand DownExpand Up@@ -293,7 +299,7 @@ def write_tree_from_cache(entries: List[IndexEntry], odb, sl: slice, si: int = 0
# finally create the tree
sio = BytesIO()
tree_to_stream(tree_items, sio.write) # converts bytes of each item[0] to str
tree_items_stringified = cast(List[Tuple[str, int, str]], tree_items) # type: List[Tuple[str, int, str]]
tree_items_stringified = cast(List[Tuple[str, int, str]], tree_items)
sio.seek(0)

istream = odb.store(IStream(str_tree_type, len(sio.getvalue()), sio))
Expand Down
4 changes: 2 additions & 2 deletionsgit/objects/commit.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,7 @@
from git.util import (
hex_to_bin,
Actor,
Iterable,
IterableObj,
Stats,
finalize_process
)
Expand DownExpand Up@@ -47,7 +47,7 @@
__all__ = ('Commit', )


class Commit(base.Object,Iterable, Diffable, Traversable, Serializable):
class Commit(base.Object,IterableObj, Diffable, Traversable, Serializable):

"""Wraps a git Commit object.

Expand Down
15 changes: 12 additions & 3 deletionsgit/objects/fun.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
"""Module with functions which are supposed to be as fast as possible"""
from stat import S_ISDIR

from git.compat import (
safe_decode,
defenc
)

# typing ----------------------------------------------

from typing import List, Tuple


# ---------------------------------------------------


__all__ = ('tree_to_stream', 'tree_entries_from_data', 'traverse_trees_recursive',
'traverse_tree_recursive')

Expand DownExpand Up@@ -38,7 +47,7 @@ def tree_to_stream(entries, write):
# END for each item


def tree_entries_from_data(data):
def tree_entries_from_data(data: bytes) -> List[Tuple[bytes, int, str]]:
"""Reads the binary representation of a tree and returns tuples of Tree items
:param data: data block with tree data (as bytes)
:return: list(tuple(binsha, mode, tree_relative_path), ...)"""
Expand DownExpand Up@@ -72,8 +81,8 @@ def tree_entries_from_data(data):

# default encoding for strings in git is utf8
# Only use the respective unicode object if the byte stream was encoded
name = data[ns:i]
name = safe_decode(name)
name_bytes = data[ns:i]
name = safe_decode(name_bytes)

# byte is NULL, get next 20
i += 1
Expand Down
21 changes: 13 additions & 8 deletionsgit/objects/submodule/base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,6 @@
import logging
import os
import stat
from typing import List
from unittest import SkipTest
import uuid

Expand All@@ -27,12 +26,13 @@
from git.objects.base import IndexObject, Object
from git.objects.util import Traversable
from git.util import (
Iterable,
IterableObj,
join_path_native,
to_native_path_linux,
RemoteProgress,
rmtree,
unbare_repo
unbare_repo,
IterableList
)
from git.util import HIDE_WINDOWS_KNOWN_ERRORS

Expand All@@ -47,6 +47,11 @@
)


# typing ----------------------------------------------------------------------


# -----------------------------------------------------------------------------

__all__ = ["Submodule", "UpdateProgress"]


Expand DownExpand Up@@ -74,7 +79,7 @@ class UpdateProgress(RemoteProgress):
# IndexObject comes via util module, its a 'hacky' fix thanks to pythons import
# mechanism which cause plenty of trouble of the only reason for packages and
# modules is refactoring - subpackages shouldn't depend on parent packages
class Submodule(IndexObject,Iterable, Traversable):
class Submodule(IndexObject,IterableObj, Traversable):

"""Implements access to a git submodule. They are special in that their sha
represents a commit in the submodule's repository which is to be checked out
Expand DownExpand Up@@ -136,12 +141,12 @@ def _set_cache_(self, attr):
# END handle attribute name

@classmethod
def _get_intermediate_items(cls, item: 'Submodule') ->List['Submodule']: # type: ignore
def _get_intermediate_items(cls, item: 'Submodule') ->IterableList['Submodule']:
""":return: all the submodules of our module repository"""
try:
return cls.list_items(item.module())
except InvalidGitRepositoryError:
return[]
returnIterableList('')
# END handle intermediate items

@classmethod
Expand DownExpand Up@@ -1153,7 +1158,7 @@ def name(self):
"""
return self._name

def config_reader(self):
def config_reader(self) -> SectionConstraint:
"""
:return: ConfigReader instance which allows you to qurey the configuration values
of this submodule, as provided by the .gitmodules file
Expand All@@ -1163,7 +1168,7 @@ def config_reader(self):
:raise IOError: If the .gitmodules file/blob could not be read"""
return self._config_parser_constrained(read_only=True)

def children(self):
def children(self) -> IterableList['Submodule']:
"""
:return: IterableList(Submodule, ...) an iterable list of submodules instances
which are children of this submodule or 0 if the submodule is not checked out"""
Expand Down
9 changes: 7 additions & 2 deletionsgit/objects/submodule/util.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,11 @@
from io import BytesIO
import weakref

from typing import TYPE_CHECKING

if TYPE_CHECKING:
from .base import Submodule

__all__ = ('sm_section', 'sm_name', 'mkhead', 'find_first_remote_branch',
'SubmoduleConfigParser')

Expand DownExpand Up@@ -60,12 +65,12 @@ def __init__(self, *args, **kwargs):
super(SubmoduleConfigParser, self).__init__(*args, **kwargs)

#{ Interface
def set_submodule(self, submodule):
def set_submodule(self, submodule: 'Submodule') -> None:
"""Set this instance's submodule. It must be called before
the first write operation begins"""
self._smref = weakref.ref(submodule)

def flush_to_index(self):
def flush_to_index(self) -> None:
"""Flush changes in our configuration file to the index"""
assert self._smref is not None
# should always have a file here
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp