Skip to content
This repository was archived by the owner on Sep 5, 2023. It is now read-only.

Commit ed9d7dc

Browse files
committed
chore: Pre-commit hooks, black formatting, etc
- Added pre-commit hooks to repo. - Added black formatting for Python code. - Styling fixes due to the pre-commit hooks. - Update prompt_toolkit to 3.0 (should fix FuzzyCompleter issue) - Added venv path to VS Code for pylint imports issue
1 parent ef9c3ad commit ed9d7dc

File tree

9 files changed

+82
-27
lines changed

9 files changed

+82
-27
lines changed

.pre-commit-config.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v2.4.0
4+
hooks:
5+
- id: check-yaml
6+
- id: end-of-file-fixer
7+
- id: trailing-whitespace
8+
- repo: https://github.com/psf/black
9+
rev: 19.10b0
10+
hooks:
11+
- id: black

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"python.pythonPath": ".venv/bin/python"
3+
}

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,4 +671,4 @@ into proprietary programs. If your program is a subroutine library, you
671671
may consider it more useful to permit linking proprietary applications with
672672
the library. If this is what you want to do, use the GNU Lesser General
673673
Public License instead of this License. But first, please read
674-
<https://www.gnu.org/licenses/why-not-lgpl.html>.
674+
<https://www.gnu.org/licenses/why-not-lgpl.html>.

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
<br><br>
66
<a href="https://badge.fury.io/py/conventional-commit"><img src="https://badge.fury.io/py/conventional-commit.svg" alt="PyPI version" height="18"></a>
77
<a href="https://travis-ci.org/nebbles/gitcommit/branches"><img src="https://travis-ci.org/nebbles/gitcommit.svg?branch=master" alt="Travis CI build" height="18"></a>
8+
<a href="https://github.com/psf/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Code style: black" height="18"></a>
89
</p>
910

11+
1012
# Install
1113

1214
To install
@@ -42,7 +44,7 @@ Additional rules implemeted:
4244

4345
# Development
4446

45-
The old distribution method is documented in
47+
The old distribution method is documented in
4648
[docs/dev_distibution_legacy.md](docs/dev_distribution_legacy.md)
4749

4850
*Note: if modifying `.travis.yml` you should verify it by running `travis lint .travis.yml`*

docs/dev_distribution_legacy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The following instructions explain how this command-line application is
44
distributed. We deploy our builds to the Python Package Index for distribution.
5-
This allows users to install the application with a simple
5+
This allows users to install the application with a simple
66
`pip install conventional-commit`.
77

88
First ensure necessary packages are installed

gitcommit/completers.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from prompt_toolkit.completion import ( # pylint: disable=no-name-in-module
1+
from prompt_toolkit.completion import (
22
Completer,
33
Completion,
44
FuzzyCompleter,
@@ -46,9 +46,7 @@ def __init__(self):
4646
"test": "any work to tests",
4747
"wip": "work in progress / might not build",
4848
}
49-
super().__init__(
50-
self.meta_dict.keys(), meta_dict=self.meta_dict, WORD=False,
51-
)
49+
super().__init__(self.meta_dict.keys(), meta_dict=self.meta_dict, WORD=False)
5250

5351

5452
class FooterCompleter(FuzzyWordCompleter):
@@ -68,6 +66,5 @@ def __init__(self):
6866
"Clubhouse [branch ch": "Associates branch with ticket",
6967
}
7068
super().__init__(
71-
self.footer_meta_dict.keys(), meta_dict=self.footer_meta_dict, WORD=False,
69+
self.footer_meta_dict.keys(), meta_dict=self.footer_meta_dict, WORD=False
7270
)
73-

gitcommit/gitcommit.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ class LineLengthPrompt:
5151
def __init__(self, length_limit, session):
5252
self.limit = length_limit
5353
self.session = session
54-
self.invalid_style = Style.from_dict({"rprompt": "bg:#ff0066 #000000",})
55-
self.valid_style = Style.from_dict({"rprompt": "bg:#b0f566 #000000",})
54+
self.invalid_style = Style.from_dict({"rprompt": "bg:#ff0066 #000000"})
55+
self.valid_style = Style.from_dict({"rprompt": "bg:#b0f566 #000000"})
5656

5757
def get_text(self):
5858
text = get_app().current_buffer.text
@@ -126,7 +126,7 @@ def add_type(commit_msg):
126126
break_long_words=False,
127127
)
128128
# ensure each line has trailing whitespace, then do join
129-
type_descr_str = "".join(map(lambda l: l.ljust(type_descr_width), descr_lines,))
129+
type_descr_str = "".join(map(lambda l: l.ljust(type_descr_width), descr_lines))
130130

131131
# Combine type name with type description
132132
type_print = prefixes[i].ljust(prefix_length) + type_descr_str
@@ -140,7 +140,7 @@ def add_type(commit_msg):
140140
print()
141141
text = Ansi.b_green("Type: ")
142142
c_type = prompt(
143-
ANSI(text), completer=TypeCompleter(), validator=TypeValidator(valid_inputs),
143+
ANSI(text), completer=TypeCompleter(), validator=TypeValidator(valid_inputs)
144144
)
145145

146146
# Convert from number back to proper type name
@@ -368,7 +368,7 @@ def run():
368368
# Warn of extra command line arguments
369369
if len(sys.argv) > 1:
370370
Ansi.print_warning(
371-
"The following additional arguments will be passed to git commit: ", end="",
371+
"The following additional arguments will be passed to git commit: ", end=""
372372
)
373373
Ansi.print_warning(sys.argv[1:])
374374
argv_passthrough = sys.argv[1:] # overwrite default list

poetry.lock

Lines changed: 53 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ gitcommit = 'gitcommit.gitcommit:main'
2222

2323
[tool.poetry.dependencies]
2424
python = "^3.6"
25-
prompt_toolkit = "^2.0"
25+
prompt_toolkit = "^3.0"
2626
requests = "^2.22"
2727
pyperclip = "^1.7"
2828

2929
[tool.poetry.dev-dependencies]
30+
black = {version = "^18.3-alpha.0", allows-prereleases = true}
3031

3132
[build-system]
3233
requires = ["poetry>=0.12"]

0 commit comments

Comments
 (0)