Skip to content

Drop 3.6, increase type strictness #1311

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 36 commits into from
Aug 3, 2021
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
39d37d5
replace some TBDs wiht runtime types
Yobmod Jul 31, 2021
c878771
replace more TBDs wiht runtime types
Yobmod Jul 31, 2021
009017e
Merge branch 'gitpython-developers:main' into main
Yobmod Aug 2, 2021
2163322
increase mypy strictness (warn unused ignored)
Yobmod Aug 2, 2021
0525c17
Merge branch 'main' of https://github.com/Yobmod/GitPython
Yobmod Aug 2, 2021
91fce33
increase mypy strictness (warn unused ignored and warn unreachable)
Yobmod Aug 2, 2021
15ace87
rmv 3.6 from CI matrix
Yobmod Aug 2, 2021
bef2182
rmv 3.6 from setup.py
Yobmod Aug 2, 2021
270c3d7
rmv 3.6 README
Yobmod Aug 2, 2021
c3f3501
Add __future__.annotations to cmd.py
Yobmod Aug 2, 2021
829142d
Add __future__.annotations to cmd.py2
Yobmod Aug 2, 2021
13e0730
Fix parse_date typing
Yobmod Aug 2, 2021
730f119
Fix parse_date typing 2
Yobmod Aug 2, 2021
2fe13ca
Fix parse_date typing 3
Yobmod Aug 2, 2021
024b696
Fix parse_date typing 4
Yobmod Aug 2, 2021
e2f8367
Fix parse_date typing 5
Yobmod Aug 2, 2021
d30bc07
Fix parse_date typing 6
Yobmod Aug 2, 2021
6470ad4
Fix parse_date typing 7
Yobmod Aug 2, 2021
481f672
Add __future__.annotations to repo/base.py
Yobmod Aug 2, 2021
9de7310
Minor type fixes
Yobmod Aug 2, 2021
5647d58
Merge branch 'gitpython-developers:main' into main
Yobmod Aug 2, 2021
f34a39f
Test new union syntax (Pep604)
Yobmod Aug 2, 2021
3b53d28
Merge branch 'main' of https://github.com/Yobmod/GitPython
Yobmod Aug 2, 2021
4dd06c3
Test trailing comma in args (>py3.6?)
Yobmod Aug 2, 2021
94ae0c5
Test Dataclass in repo.base.blame()
Yobmod Aug 2, 2021
a3f5b13
Test Dataclass in repo.base.blame() 2
Yobmod Aug 2, 2021
a2a36e0
Test Dataclass in repo.base.blame() 3
Yobmod Aug 2, 2021
ed137cb
Test TypedDict in repo.base.blame() 2
Yobmod Aug 2, 2021
e4761ff
Test TypedDict in repo.base.blame() 1
Yobmod Aug 2, 2021
1aaa704
Test Dataclass in repo.base.blame() 4
Yobmod Aug 2, 2021
bc9bcf5
Test Dataclass in repo.base.blame() 5
Yobmod Aug 2, 2021
ad417ba
Test Dataclass in repo.base.blame() 6
Yobmod Aug 2, 2021
ecb1f79
Choose TypedDict!
Yobmod Aug 2, 2021
5aa8c34
Improve type of repo.blame_incremental()
Yobmod Aug 2, 2021
8b8aa16
Improve type of repo.currently_rebasing_on()
Yobmod Aug 2, 2021
84232f7
Add Typing :: Typed to setup.py
Yobmod Aug 3, 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
Prev Previous commit
Next Next commit
Test TypedDict in repo.base.blame() 2
  • Loading branch information
Yobmod committed Aug 2, 2021
commit ed137cbddf69ae11e5287a9e96e1df1a6e71250d
80 changes: 36 additions & 44 deletions git/repo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import logging
import os
import re
from dataclasses import dataclass
import shlex
import warnings
from gitdb.db.loose import LooseObjectDB
Expand Down Expand Up @@ -902,21 +901,7 @@ class InfoTD(TypedDict, total=False):
committer_email: str
committer_date: int

@dataclass
class InfoDC(Dict[str, Union[str, int]]):
sha: str = ''
id: str = ''
filename: str = ''
summary: str = ''
author: str = ''
author_email: str = ''
author_date: int = 0
committer: str = ''
committer_email: str = ''
committer_date: int = 0

# info: InfoTD = {}
info = InfoDC()
info: InfoTD = {}

keepends = True
for line_bytes in data.splitlines(keepends):
Expand All @@ -943,10 +928,10 @@ class InfoDC(Dict[str, Union[str, int]]):
# another line of blame with the same data
digits = parts[-1].split(" ")
if len(digits) == 3:
info.id = firstpart
info = {'id': firstpart}
blames.append([None, []])
elif info.id != firstpart:
info.id = firstpart
elif info['id'] != firstpart:
info = {'id': firstpart}
blames.append([commits.get(firstpart), []])
# END blame data initialization
else:
Expand All @@ -962,12 +947,20 @@ class InfoDC(Dict[str, Union[str, int]]):
# committer-time 1192271832
# committer-tz -0700 - IGNORED BY US
role = m.group(0)
if firstpart.endswith('-mail'):
info[f"{role}_email"] = parts[-1]
elif firstpart.endswith('-time'):
info[f"{role}_date"] = int(parts[-1])
elif role == firstpart:
info[role] = parts[-1]
if role == 'author':
if firstpart.endswith('-mail'):
info["author_email"] = parts[-1]
elif firstpart.endswith('-time'):
info["author_date"] = int(parts[-1])
elif role == firstpart:
info["author"] = parts[-1]
elif role == 'committer':
if firstpart.endswith('-mail'):
info["committer_email"] = parts[-1]
elif firstpart.endswith('-time'):
info["committer_date"] = int(parts[-1])
elif role == firstpart:
info["committer"] = parts[-1]
# END distinguish mail,time,name
else:
# handle
Expand All @@ -980,34 +973,33 @@ class InfoDC(Dict[str, Union[str, int]]):
info['summary'] = parts[-1]
elif firstpart == '':
if info:
sha = info.id
sha = info['id']
c = commits.get(sha)
if c is None:
c = Commit(self, hex_to_bin(sha),
author=Actor._from_string(info.author + ' ' + info.author_email),
authored_date=info.author_date,
author=Actor._from_string(info['author'] + ' ' + info['author_email']),
authored_date=info['author_date'],
committer=Actor._from_string(
info.committer + ' ' + info.committer_email),
committed_date=info.committer_date)
info['committer'] + ' ' + info['committer_email']),
committed_date=info['committer_date'])
commits[sha] = c
blames[-1][0] = c
# END if commit objects needs initial creation
if not is_binary:
if line_str and line_str[0] == '\t':
line_str = line_str[1:]
line_AnyStr: str | bytes = line_str
else:
line_AnyStr = line_bytes
# NOTE: We are actually parsing lines out of binary data, which can lead to the
# binary being split up along the newline separator. We will append this to the
# blame we are currently looking at, even though it should be concatenated with
# the last line we have seen.

# end handle line contents
if blames[-1][1] is not None:
blames[-1][1].append(line_AnyStr)
if not is_binary:
if line_str and line_str[0] == '\t':
line_str = line_str[1:]

blames[-1][1].append(line_str)
else:
# NOTE: We are actually parsing lines out of binary data, which can lead to the
# binary being split up along the newline separator. We will append this to the
# blame we are currently looking at, even though it should be concatenated with
# the last line we have seen.
blames[-1][1].append(line_bytes)
# end handle line contents

info.id = sha
info = {'id': sha}
# END if we collected commit info
# END distinguish filename,summary,rest
# END distinguish author|committer vs filename,summary,rest
Expand Down