Skip to content

Commit

Permalink
add auto-formatter GHA triggered by PR (#427)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
junkmd and github-actions[bot] authored Dec 30, 2022
1 parent 12d22a2 commit 22bfc50
Show file tree
Hide file tree
Showing 81 changed files with 3,800 additions and 2,062 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/autofmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
on:
pull_request:
branches: [drop_py2] # TODO: add `master`

jobs:
formatter:
name: auto-formatter
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Install black
run: pip install black==22.12.0
- name: Format
run: python -m black comtypes/.
- name: Auto-commit
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: ${{ github.head_ref }}
commit_message: apply automatic formatter
commit_user_name: github-actions[bot]
commit_user_email: 41898282+github-actions[bot]@users.noreply.github.com
commit_author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
17 changes: 9 additions & 8 deletions comtypes/GUID.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
import sys

if sys.version_info >= (2, 6):

def binary(obj):
return bytes(obj)

else:

def binary(obj):
return buffer(obj)


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


class GUID(Structure):
_fields_ = [("Data1", DWORD),
("Data2", WORD),
("Data3", WORD),
("Data4", BYTE * 8)]
_fields_ = [("Data1", DWORD), ("Data2", WORD), ("Data3", WORD), ("Data4", BYTE * 8)]

def __init__(self, name=None):
if name is not None:
Expand All @@ -50,6 +52,7 @@ def __unicode__(self):
result = p.value
_CoTaskMemFree(p)
return result

__str__ = __unicode__

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

def __eq__(self, other):
return isinstance(other, GUID) and \
binary(self) == binary(other)
return isinstance(other, GUID) and binary(self) == binary(other)

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

@classmethod
def from_progid(cls, progid):
"""Get guid from progid, ...
"""
"""Get guid from progid, ..."""
if hasattr(progid, "_reg_clsid_"):
progid = progid._reg_clsid_
if isinstance(progid, cls):
Expand Down
Loading

0 comments on commit 22bfc50

Please sign in to comment.