Skip to content

Commit ec11448

Browse files
committed
Dropped support for Python 2
No longer depend on `six` or `mock`. Provided a fatal error if the module is imported into a Python 2 environment. Fixed the flask dependency on a version > 1.0
1 parent e9a70dd commit ec11448

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

github_webhook/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
:license: Apache License, Version 2.0
99
"""
1010

11+
from textwrap import dedent
12+
13+
import sys
14+
if sys.version_info[0] < 3:
15+
raise Exception(
16+
dedent("""Python runtime with major version >= 3 is required:
17+
currently running on Python {version}""".format(
18+
version=sys.version_info[0])))
19+
1120
from github_webhook.webhook import Webhook
1221

1322
# -----------------------------------------------------------------------------

github_webhook/webhook.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import hmac
44
import logging
55

6-
import six
76
from flask import abort, request
87

98

@@ -22,7 +21,7 @@ def __init__(self, app, endpoint='/postreceive', secret=None):
2221

2322
self._hooks = collections.defaultdict(list)
2423
self._logger = logging.getLogger('webhook')
25-
if secret is not None and not isinstance(secret, six.binary_type):
24+
if secret is not None and not isinstance(secret, bytes):
2625
secret = secret.encode('utf-8')
2726
self._secret = secret
2827

@@ -53,8 +52,8 @@ def _postreceive(self):
5352

5453
if digest is not None:
5554
sig_parts = _get_header('X-Hub-Signature').split('=', 1)
56-
if not isinstance(digest, six.text_type):
57-
digest = six.text_type(digest)
55+
if not isinstance(digest, str):
56+
digest = str(digest)
5857

5958
if (len(sig_parts) < 2 or sig_parts[0] != 'sha1'
6059
or not hmac.compare_digest(sig_parts[1], digest)):

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
from setuptools import setup
22

33
setup(name="github-webhook",
4-
version="1.0.2",
4+
version="1.0.3",
55
description="Very simple, but powerful, microframework for writing Github webhooks in Python",
66
url="https://github.com/bloomberg/python-github-webhook",
77
author="Alex Chamberlain, Fred Phillips, Daniel Kiss, Daniel Beer",
88
author_email="achamberlai9@bloomberg.net, fphillips7@bloomberg.net, dkiss1@bloomberg.net, dbeer1@bloomberg.net",
99
license='Apache 2.0',
1010
packages=["github_webhook"],
11-
install_requires=['flask', 'six'],
11+
install_requires=['flask==1.0.2'],
1212
tests_require=['mock', 'nose'],
1313

1414
classifiers=[

0 commit comments

Comments
 (0)