Skip to content

Commit 22bfc50

Browse files
add auto-formatter GHA triggered by PR (enthought#427)
* add `# fmt: ...` for avoiding redundant format * add GHA setting * apply automatic formatter Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 12d22a2 commit 22bfc50

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+3800
-2062
lines changed

.github/workflows/autofmt.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
on:
2+
pull_request:
3+
branches: [drop_py2] # TODO: add `master`
4+
5+
jobs:
6+
formatter:
7+
name: auto-formatter
8+
runs-on: windows-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v3
12+
- name: Set up Python
13+
uses: actions/setup-python@v4
14+
with:
15+
python-version: 3.7
16+
- name: Install black
17+
run: pip install black==22.12.0
18+
- name: Format
19+
run: python -m black comtypes/.
20+
- name: Auto-commit
21+
uses: stefanzweifel/git-auto-commit-action@v4
22+
with:
23+
branch: ${{ github.head_ref }}
24+
commit_message: apply automatic formatter
25+
commit_user_name: github-actions[bot]
26+
commit_user_email: 41898282+github-actions[bot]@users.noreply.github.com
27+
commit_author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

comtypes/GUID.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22
import sys
33

44
if sys.version_info >= (2, 6):
5+
56
def binary(obj):
67
return bytes(obj)
8+
79
else:
10+
811
def binary(obj):
912
return buffer(obj)
1013

14+
1115
if sys.version_info >= (3, 0):
1216
text_type = str
1317
base_text_type = str
@@ -31,11 +35,9 @@ def binary(obj):
3135
# Note: Comparing GUID instances by comparing their buffers
3236
# is slightly faster than using ole32.IsEqualGUID.
3337

38+
3439
class GUID(Structure):
35-
_fields_ = [("Data1", DWORD),
36-
("Data2", WORD),
37-
("Data3", WORD),
38-
("Data4", BYTE * 8)]
40+
_fields_ = [("Data1", DWORD), ("Data2", WORD), ("Data3", WORD), ("Data4", BYTE * 8)]
3941

4042
def __init__(self, name=None):
4143
if name is not None:
@@ -50,6 +52,7 @@ def __unicode__(self):
5052
result = p.value
5153
_CoTaskMemFree(p)
5254
return result
55+
5356
__str__ = __unicode__
5457

5558
def __cmp__(self, other):
@@ -61,8 +64,7 @@ def __bool__(self):
6164
return self != GUID_null
6265

6366
def __eq__(self, other):
64-
return isinstance(other, GUID) and \
65-
binary(self) == binary(other)
67+
return isinstance(other, GUID) and binary(self) == binary(other)
6668

6769
def __hash__(self):
6870
# We make GUID instances hashable, although they are mutable.
@@ -73,8 +75,7 @@ def copy(self):
7375

7476
@classmethod
7577
def from_progid(cls, progid):
76-
"""Get guid from progid, ...
77-
"""
78+
"""Get guid from progid, ..."""
7879
if hasattr(progid, "_reg_clsid_"):
7980
progid = progid._reg_clsid_
8081
if isinstance(progid, cls):

0 commit comments

Comments
 (0)