Skip to content

Commit cfcae1d

Browse files
authored
Merge pull request #1318 from Yobmod/main
General fixes for next release
2 parents 5da76e8 + bb9b50f commit cfcae1d

File tree

12 files changed

+106
-60
lines changed

12 files changed

+106
-60
lines changed

Diff for: .github/workflows/pythonpackage.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
python-version: [3.7, 3.8, 3.9, "3.10.0-beta.4"]
18+
python-version: [3.7, 3.7.5, 3.7.12, 3.8, 3.8.0, 3.8.11, 3.8, 3.9, 3.9.0, 3.9.7] # , "3.10.0-rc.2"]
1919

2020
steps:
2121
- uses: actions/checkout@v2

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ nbproject
2222
.pytest_cache/
2323
monkeytype.sqlite3
2424
output.txt
25+
tox.ini

Diff for: VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.1.20
1+
3.1.21

Diff for: doc/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
sphinx==4.1.1
1+
sphinx==4.1.2
22
sphinx_rtd_theme
33
sphinx-autodoc-typehints

Diff for: doc/source/changes.rst

+53-25
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,60 @@
22
Changelog
33
=========
44

5-
3.1.20
5+
3.1.21
66
======
77

8-
* This is the second typed release with a lot of improvements under the hood.
8+
* This is the second typed release with a lot of improvements under the hood.
9+
10+
* General:
11+
- Remove python 3.6 support
12+
- Remove distutils ahead of deprecation in standard library.
13+
- Update sphinx to 4.1.12 and use autodoc-typehints.
14+
15+
* Typing:
16+
- Add types to ALL functions.
17+
- Ensure py.typed is collected.
18+
- Increase mypy strictness with disallow_untyped_defs, warn_redundant_casts, warn_unreachable.
19+
- Use typing.NamedTuple and typing.OrderedDict now 3.6 dropped.
20+
- Make Protocol classes ABCs at runtime due to new bug in 3.10.0-rc1
21+
- Remove use of typing.TypeGuard until later release, to allow dependant libs time to update.
22+
- Tracking issue: https://github.com/gitpython-developers/GitPython/issues/1095
23+
24+
* Runtime improvements:
25+
- Add clone_multi_options support to submodule.add()
26+
- Delay calling get_user_id() unless essential, to support sand-boxed environments.
27+
- Add timeout to handle_process_output(), in case thread.join() hangs.
28+
29+
See the following for details:
30+
https://github.com/gitpython-developers/gitpython/milestone/52?closed=1
31+
32+
33+
3.1.20 (YANKED)
34+
===============
35+
36+
* This is the second typed release with a lot of improvements under the hood.
937
* Tracking issue: https://github.com/gitpython-developers/GitPython/issues/1095
10-
38+
1139
See the following for details:
12-
https://github.com/gitpython-developers/gitpython/milestone/52?closed=1
40+
https://github.com/gitpython-developers/gitpython/milestone/52?closed=1
1341

1442

1543
3.1.19 (YANKED)
1644
===============
1745

18-
* This is the second typed release with a lot of improvements under the hood.
46+
* This is the second typed release with a lot of improvements under the hood.
1947
* Tracking issue: https://github.com/gitpython-developers/GitPython/issues/1095
20-
48+
2149
See the following for details:
22-
https://github.com/gitpython-developers/gitpython/milestone/51?closed=1
50+
https://github.com/gitpython-developers/gitpython/milestone/51?closed=1
2351

2452
3.1.18
2553
======
2654

2755
* drop support for python 3.5 to reduce maintenance burden on typing. Lower patch levels of python 3.5 would break, too.
2856

2957
See the following for details:
30-
https://github.com/gitpython-developers/gitpython/milestone/50?closed=1
58+
https://github.com/gitpython-developers/gitpython/milestone/50?closed=1
3159

3260
3.1.17
3361
======
@@ -37,7 +65,7 @@ https://github.com/gitpython-developers/gitpython/milestone/50?closed=1
3765
* Add more static typing information
3866

3967
See the following for details:
40-
https://github.com/gitpython-developers/gitpython/milestone/49?closed=1
68+
https://github.com/gitpython-developers/gitpython/milestone/49?closed=1
4169

4270
3.1.16 (YANKED)
4371
===============
@@ -46,15 +74,15 @@ https://github.com/gitpython-developers/gitpython/milestone/49?closed=1
4674
* Add more static typing information
4775

4876
See the following for details:
49-
https://github.com/gitpython-developers/gitpython/milestone/48?closed=1
77+
https://github.com/gitpython-developers/gitpython/milestone/48?closed=1
5078

5179
3.1.15 (YANKED)
5280
===============
5381

5482
* add deprectation warning for python 3.5
5583

5684
See the following for details:
57-
https://github.com/gitpython-developers/gitpython/milestone/47?closed=1
85+
https://github.com/gitpython-developers/gitpython/milestone/47?closed=1
5886

5987
3.1.14
6088
======
@@ -65,40 +93,40 @@ https://github.com/gitpython-developers/gitpython/milestone/47?closed=1
6593
* Drop python 3.4 support
6694

6795
See the following for details:
68-
https://github.com/gitpython-developers/gitpython/milestone/46?closed=1
96+
https://github.com/gitpython-developers/gitpython/milestone/46?closed=1
6997

7098
3.1.13
7199
======
72100

73101
See the following for details:
74-
https://github.com/gitpython-developers/gitpython/milestone/45?closed=1
102+
https://github.com/gitpython-developers/gitpython/milestone/45?closed=1
75103

76104
3.1.12
77105
======
78106

79107
See the following for details:
80-
https://github.com/gitpython-developers/gitpython/milestone/44?closed=1
108+
https://github.com/gitpython-developers/gitpython/milestone/44?closed=1
81109

82110
3.1.11
83111
======
84112

85113
Fixes regression of 3.1.10.
86114

87115
See the following for details:
88-
https://github.com/gitpython-developers/gitpython/milestone/43?closed=1
116+
https://github.com/gitpython-developers/gitpython/milestone/43?closed=1
89117

90118
3.1.10
91119
======
92120

93121
See the following for details:
94-
https://github.com/gitpython-developers/gitpython/milestone/42?closed=1
122+
https://github.com/gitpython-developers/gitpython/milestone/42?closed=1
95123

96124

97125
3.1.9
98126
=====
99127

100128
See the following for details:
101-
https://github.com/gitpython-developers/gitpython/milestone/41?closed=1
129+
https://github.com/gitpython-developers/gitpython/milestone/41?closed=1
102130

103131

104132
3.1.8
@@ -109,7 +137,7 @@ https://github.com/gitpython-developers/gitpython/milestone/41?closed=1
109137

110138

111139
See the following for more details:
112-
https://github.com/gitpython-developers/gitpython/milestone/40?closed=1
140+
https://github.com/gitpython-developers/gitpython/milestone/40?closed=1
113141

114142

115143
3.1.7
@@ -135,13 +163,13 @@ https://github.com/gitpython-developers/gitpython/milestone/40?closed=1
135163
* package size was reduced significantly not placing tests into the package anymore.
136164

137165
See the following for details:
138-
https://github.com/gitpython-developers/gitpython/milestone/39?closed=1
166+
https://github.com/gitpython-developers/gitpython/milestone/39?closed=1
139167

140168
3.1.3
141169
=====
142170

143171
See the following for details:
144-
https://github.com/gitpython-developers/gitpython/milestone/38?closed=1
172+
https://github.com/gitpython-developers/gitpython/milestone/38?closed=1
145173

146174
3.1.2
147175
=====
@@ -190,7 +218,7 @@ Bugfixes
190218
Bugfixes
191219
--------
192220

193-
* Fixed Repo.__repr__ when subclassed
221+
* Fixed Repo.__repr__ when subclassed
194222
(`#968 <https://github.com/gitpython-developers/GitPython/pull/968>`_)
195223
* Removed compatibility shims for Python < 3.4 and old mock library
196224
* Replaced usage of deprecated unittest aliases and Logger.warn
@@ -213,7 +241,7 @@ Bugfixes
213241
--------
214242

215243
* Fixed warning for usage of environment variables for paths containing ``$`` or ``%``
216-
(`#832 <https://github.com/gitpython-developers/GitPython/issues/832>`_,
244+
(`#832 <https://github.com/gitpython-developers/GitPython/issues/832>`_,
217245
`#961 <https://github.com/gitpython-developers/GitPython/pull/961>`_)
218246
* Added support for parsing Git internal date format (@<unix timestamp> <timezone offset>)
219247
(`#965 <https://github.com/gitpython-developers/GitPython/pull/965>`_)
@@ -371,7 +399,7 @@ Notable fixes
371399
* The `GIT_DIR` environment variable does not override the `path` argument when
372400
initializing a `Repo` object anymore. However, if said `path` unset, `GIT_DIR`
373401
will be used to fill the void.
374-
402+
375403
All issues and PRs can be viewed in all detail when following this URL:
376404
https://github.com/gitpython-developers/GitPython/issues?q=is%3Aclosed+milestone%3A%22v2.1.0+-+proper+windows+support%22
377405

@@ -401,7 +429,7 @@ https://github.com/gitpython-developers/GitPython/issues?q=is%3Aclosed+milestone
401429
2.0.7 - New Features
402430
====================
403431

404-
* `IndexFile.commit(...,skip_hooks=False)` added. This parameter emulates the
432+
* `IndexFile.commit(...,skip_hooks=False)` added. This parameter emulates the
405433
behaviour of `--no-verify` on the command-line.
406434

407435
2.0.6 - Fixes and Features
@@ -441,7 +469,7 @@ https://github.com/gitpython-developers/GitPython/issues?q=is%3Aclosed+milestone
441469
commit messages contained ``\r`` characters
442470
* Fix: progress handler exceptions are not caught anymore, which would usually just hide bugs
443471
previously.
444-
* Fix: The `Git.execute` method will now redirect `stdout` to `devnull` if `with_stdout` is false,
472+
* Fix: The `Git.execute` method will now redirect `stdout` to `devnull` if `with_stdout` is false,
445473
which is the intended behaviour based on the parameter's documentation.
446474

447475
2.0.2 - Fixes

Diff for: git/cmd.py

+28-14
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# This module is part of GitPython and is released under
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
6-
6+
from __future__ import annotations
77
from contextlib import contextmanager
88
import io
99
import logging
@@ -68,7 +68,7 @@
6868
# Documentation
6969
## @{
7070

71-
def handle_process_output(process: Union[subprocess.Popen, 'Git.AutoInterrupt'],
71+
def handle_process_output(process: 'Git.AutoInterrupt' | Popen,
7272
stdout_handler: Union[None,
7373
Callable[[AnyStr], None],
7474
Callable[[List[AnyStr]], None],
@@ -78,7 +78,8 @@ def handle_process_output(process: Union[subprocess.Popen, 'Git.AutoInterrupt'],
7878
Callable[[List[AnyStr]], None]],
7979
finalizer: Union[None,
8080
Callable[[Union[subprocess.Popen, 'Git.AutoInterrupt']], None]] = None,
81-
decode_streams: bool = True) -> None:
81+
decode_streams: bool = True,
82+
timeout: float = 10.0) -> None:
8283
"""Registers for notifications to learn that process output is ready to read, and dispatches lines to
8384
the respective line handlers.
8485
This function returns once the finalizer returns
@@ -93,9 +94,10 @@ def handle_process_output(process: Union[subprocess.Popen, 'Git.AutoInterrupt'],
9394
their contents to handlers.
9495
Set it to False if `universal_newline == True` (then streams are in text-mode)
9596
or if decoding must happen later (i.e. for Diffs).
97+
:param timeout: float, timeout to pass to t.join() in case it hangs. Default = 10.0 seconds
9698
"""
9799
# Use 2 "pump" threads and wait for both to finish.
98-
def pump_stream(cmdline: str, name: str, stream: Union[BinaryIO, TextIO], is_decode: bool,
100+
def pump_stream(cmdline: List[str], name: str, stream: Union[BinaryIO, TextIO], is_decode: bool,
99101
handler: Union[None, Callable[[Union[bytes, str]], None]]) -> None:
100102
try:
101103
for line in stream:
@@ -107,22 +109,32 @@ def pump_stream(cmdline: str, name: str, stream: Union[BinaryIO, TextIO], is_dec
107109
else:
108110
handler(line)
109111
except Exception as ex:
110-
log.error("Pumping %r of cmd(%s) failed due to: %r", name, remove_password_if_present(cmdline), ex)
111-
raise CommandError(['<%s-pump>' % name] + remove_password_if_present(cmdline), ex) from ex
112+
log.error(f"Pumping {name!r} of cmd({remove_password_if_present(cmdline)}) failed due to: {ex!r}")
113+
raise CommandError([f'<{name}-pump>'] + remove_password_if_present(cmdline), ex) from ex
112114
finally:
113115
stream.close()
114116

115-
cmdline = getattr(process, 'args', '') # PY3+ only
117+
if hasattr(process, 'proc'):
118+
process = cast('Git.AutoInterrupt', process)
119+
cmdline: str | Tuple[str, ...] | List[str] = getattr(process.proc, 'args', '')
120+
p_stdout = process.proc.stdout if process.proc else None
121+
p_stderr = process.proc.stderr if process.proc else None
122+
else:
123+
process = cast(Popen, process)
124+
cmdline = getattr(process, 'args', '')
125+
p_stdout = process.stdout
126+
p_stderr = process.stderr
127+
116128
if not isinstance(cmdline, (tuple, list)):
117129
cmdline = cmdline.split()
118130

119-
pumps = []
120-
if process.stdout:
121-
pumps.append(('stdout', process.stdout, stdout_handler))
122-
if process.stderr:
123-
pumps.append(('stderr', process.stderr, stderr_handler))
131+
pumps: List[Tuple[str, IO, Callable[..., None] | None]] = []
132+
if p_stdout:
133+
pumps.append(('stdout', p_stdout, stdout_handler))
134+
if p_stderr:
135+
pumps.append(('stderr', p_stderr, stderr_handler))
124136

125-
threads = []
137+
threads: List[threading.Thread] = []
126138

127139
for name, stream, handler in pumps:
128140
t = threading.Thread(target=pump_stream,
@@ -134,7 +146,9 @@ def pump_stream(cmdline: str, name: str, stream: Union[BinaryIO, TextIO], is_dec
134146
## FIXME: Why Join?? Will block if `stdin` needs feeding...
135147
#
136148
for t in threads:
137-
t.join()
149+
t.join(timeout=timeout)
150+
if t.is_alive():
151+
raise RuntimeError(f"Thread join() timed out in cmd.handle_process_output(). Timeout={timeout} seconds")
138152

139153
if finalizer:
140154
return finalizer(process)

Diff for: git/config.py

+1-10
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
# typing-------------------------------------------------------
3232

3333
from typing import (Any, Callable, Generic, IO, List, Dict, Sequence,
34-
TYPE_CHECKING, Tuple, TypeVar, Union, cast, overload)
34+
TYPE_CHECKING, Tuple, TypeVar, Union, cast)
3535

3636
from git.types import Lit_config_levels, ConfigLevels_Tup, PathLike, assert_never, _T
3737

@@ -709,15 +709,6 @@ def read_only(self) -> bool:
709709
""":return: True if this instance may change the configuration file"""
710710
return self._read_only
711711

712-
@overload
713-
def get_value(self, section: str, option: str, default: None = None) -> Union[int, float, str, bool]: ...
714-
715-
@overload
716-
def get_value(self, section: str, option: str, default: str) -> str: ...
717-
718-
@overload
719-
def get_value(self, section: str, option: str, default: float) -> float: ...
720-
721712
def get_value(self, section: str, option: str, default: Union[int, float, str, bool, None] = None
722713
) -> Union[int, float, str, bool]:
723714
# can default or return type include bool?

Diff for: git/objects/commit.py

+2
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,8 @@ def create_from_tree(cls, repo: 'Repo', tree: Union[Tree, str], message: str,
446446
# assume utf8 encoding
447447
enc_section, enc_option = cls.conf_encoding.split('.')
448448
conf_encoding = cr.get_value(enc_section, enc_option, cls.default_encoding)
449+
if not isinstance(conf_encoding, str):
450+
raise TypeError("conf_encoding could not be coerced to str")
449451

450452
# if the tree is no object, make sure we create one - otherwise
451453
# the created commit object is invalid

Diff for: git/objects/util.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66
"""Module for general utility functions"""
77

8-
from abc import abstractmethod
8+
from abc import ABC, abstractmethod
99
import warnings
1010
from git.util import (
1111
IterableList,
@@ -22,10 +22,10 @@
2222
from datetime import datetime, timedelta, tzinfo
2323

2424
# typing ------------------------------------------------------------
25-
from typing import (Any, Callable, Deque, Iterator, NamedTuple, overload, Sequence,
25+
from typing import (Any, Callable, Deque, Iterator, Generic, NamedTuple, overload, Sequence, # NOQA: F401
2626
TYPE_CHECKING, Tuple, Type, TypeVar, Union, cast)
2727

28-
from git.types import Has_id_attribute, Literal, Protocol, runtime_checkable
28+
from git.types import Has_id_attribute, Literal, _T # NOQA: F401
2929

3030
if TYPE_CHECKING:
3131
from io import BytesIO, StringIO
@@ -35,6 +35,13 @@
3535
from .tree import Tree, TraversedTreeTup
3636
from subprocess import Popen
3737
from .submodule.base import Submodule
38+
from git.types import Protocol, runtime_checkable
39+
else:
40+
# Protocol = Generic[_T] # NNeeded for typing bug #572?
41+
Protocol = ABC
42+
43+
def runtime_checkable(f):
44+
return f
3845

3946

4047
class TraverseNT(NamedTuple):

0 commit comments

Comments
 (0)