Skip to content

Commit 0ce2393

Browse files
committed
blacken code
1 parent 5a06d0e commit 0ce2393

File tree

6 files changed

+39
-24
lines changed

6 files changed

+39
-24
lines changed

mkdocs_git_authors_plugin/ci.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from mkdocs_git_authors_plugin.git.command import GitCommand
1414

15+
1516
@contextmanager
1617
def working_directory(path):
1718
"""
@@ -47,7 +48,6 @@ def raise_ci_warnings(path: str) -> None:
4748

4849
n_commits = commit_count()
4950

50-
5151
# Gitlab Runners
5252
if os.getenv("GITLAB_CI") is not None and n_commits < 50:
5353
# Default is GIT_DEPTH of 50 for gitlab
@@ -109,9 +109,9 @@ def commit_count() -> int:
109109
Returns:
110110
count (int): Number of commits.
111111
"""
112-
gc = GitCommand('rev-list',['--count','HEAD'])
112+
gc = GitCommand("rev-list", ["--count", "HEAD"])
113113
gc.run()
114-
n_commits = int(gc._stdout[0]) # type: ignore
114+
n_commits = int(gc._stdout[0]) # type: ignore
115115
assert n_commits >= 0
116116
return n_commits
117117

mkdocs_git_authors_plugin/git/commit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def __init__(
3636

3737
# Replace <>
3838
# from '<[email protected]>'
39-
39+
4040
author_email = re.sub(r"\<|\>", "", author_email)
4141
# Lowercase, as emails are not case sensitive.
4242
# See https://github.com/timvink/mkdocs-git-authors-plugin/issues/59

mkdocs_git_authors_plugin/git/page.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,20 @@ def get_authors(self):
6262
"""
6363
if not self._sorted:
6464
repo = self.repo()
65-
reverse = repo.config("show_line_count") or repo.config("show_contribution") or repo.config("sort_authors_by") == "contribution"
65+
reverse = (
66+
repo.config("show_line_count")
67+
or repo.config("show_contribution")
68+
or repo.config("sort_authors_by") == "contribution"
69+
)
6670
self._authors = sorted(self._authors, key=repo._sort_key, reverse=reverse)
6771
self._sorted = True
6872
author_threshold = repo.config("authorship_threshold_percent")
6973
if author_threshold > 0 and len(self._authors) > 1:
70-
self._authors = [a for a in self._authors if a.contribution()*100 > author_threshold]
74+
self._authors = [
75+
a
76+
for a in self._authors
77+
if a.contribution() * 100 > author_threshold
78+
]
7179
return self._authors
7280

7381
def _process_git_blame(self):

mkdocs_git_authors_plugin/git/repo.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def get_authors(self):
5151
"""
5252
Sorted list of authors in the repository.
5353
54-
Default sort order is by ascending names,
54+
Default sort order is by ascending names,
5555
and decending when contribution or line count is shown
5656
5757
Args:
@@ -152,7 +152,11 @@ def _sort_key(self, author):
152152
Returns:
153153
comparison key for the sorted() function,
154154
"""
155-
if self.config("show_line_count") or self.config("show_contribution") or self.config("sort_authors_by") == "contribution":
155+
if (
156+
self.config("show_line_count")
157+
or self.config("show_contribution")
158+
or self.config("sort_authors_by") == "contribution"
159+
):
156160
key = "contribution"
157161
else:
158162
key = "name"

mkdocs_git_authors_plugin/plugin.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
logger = logging.getLogger("mkdocs.plugins")
1313

14+
1415
class GitAuthorsPlugin(BasePlugin):
1516
config_scheme = (
1617
("show_contribution", config_options.Type(bool, default=False)),
@@ -49,17 +50,17 @@ def on_config(self, config, **kwargs):
4950
Returns:
5051
(updated) configuration object
5152
"""
52-
if not self.config.get('enabled'):
53+
if not self.config.get("enabled"):
5354
return config
54-
55-
assert self.config['authorship_threshold_percent'] >= 0
56-
assert self.config['authorship_threshold_percent'] <= 100
55+
56+
assert self.config["authorship_threshold_percent"] >= 0
57+
assert self.config["authorship_threshold_percent"] <= 100
5758

5859
try:
5960
self._repo = Repo()
6061
self._fallback = False
6162
self.repo().set_config(self.config)
62-
raise_ci_warnings(path = self.repo()._root)
63+
raise_ci_warnings(path=self.repo()._root)
6364
except GitCommandError:
6465
if self.config["fallback_to_empty"]:
6566
self._fallback = True
@@ -97,18 +98,18 @@ def on_files(self, files, config, **kwargs):
9798
Returns:
9899
global files collection
99100
"""
100-
if not self.config.get('enabled'):
101+
if not self.config.get("enabled"):
101102
return
102103
if self._fallback:
103104
return
104-
105+
105106
for file in files:
106107

107108
# Exclude pages specified in config
108109
excluded_pages = self.config.get("exclude", [])
109110
if exclude(file.src_path, excluded_pages):
110111
continue
111-
112+
112113
path = file.abs_src_path
113114
if path.endswith(".md"):
114115
_ = self.repo().page(path)
@@ -136,9 +137,9 @@ def on_page_content(self, html, page, config, files, **kwargs):
136137
Returns:
137138
str: HTML text of page as string
138139
"""
139-
if not self.config.get('enabled'):
140+
if not self.config.get("enabled"):
140141
return html
141-
142+
142143
# Exclude pages specified in config
143144
excluded_pages = self.config.get("exclude", [])
144145
if exclude(page.file.src_path, excluded_pages):
@@ -150,8 +151,10 @@ def on_page_content(self, html, page, config, files, **kwargs):
150151
)
151152
if list_pattern.search(html):
152153
html = list_pattern.sub(
153-
"" if self._fallback else
154-
util.site_authors_summary(self.repo().get_authors(), self.config), html
154+
""
155+
if self._fallback
156+
else util.site_authors_summary(self.repo().get_authors(), self.config),
157+
html,
155158
)
156159

157160
# Replace {{ git_page_authors }}
@@ -191,7 +194,7 @@ def on_page_context(self, context, page, config, nav, **kwargs):
191194
Returns:
192195
dict: template context variables
193196
"""
194-
if not self.config.get('enabled'):
197+
if not self.config.get("enabled"):
195198
return context
196199
if self._fallback:
197200
return context

mkdocs_git_authors_plugin/util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ def commit_datetime_string(dt: datetime):
3939
def page_authors_summary(page, config: dict):
4040
"""
4141
A summary of the authors' contributions on a page level
42-
42+
4343
Args:
4444
page (Page): Page class
4545
config (dict): plugin's config dict
46-
46+
4747
Returns:
4848
str: HTML text with authors
4949
"""
@@ -124,7 +124,7 @@ def site_authors_summary(authors, config: dict):
124124

125125
def page_authors(authors, path):
126126
"""List of dicts with info on page authors
127-
# TODO: rename to something more representative like 'authors_to_dict()'
127+
# TODO: rename to something more representative like 'authors_to_dict()'
128128
Args:
129129
authors (list): list with Author classes
130130
path (str): path to page

0 commit comments

Comments
 (0)