Skip to content

Commit

Permalink
Merge branch 'master' into latest-codegen-master
Browse files Browse the repository at this point in the history
  • Loading branch information
pakrym-stripe authored Nov 9, 2023
2 parents 4b45482 + 282e7bc commit dad14bb
Show file tree
Hide file tree
Showing 16 changed files with 46 additions and 63 deletions.
8 changes: 5 additions & 3 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
[flake8]
exclude =
stripe/six.py

# E501 is the "Line too long" error. We disable it because we use Black for
# code formatting. Black makes a best effort to keep lines under the max
# length, but can go over in some cases.
# W503 goes against PEP8 rules. It's disabled by default, but must be disabled
# explicitly when using `ignore`.
ignore = E501, W503

[flake8:local-plugins]
extension =
SPY = flake8_stripe:TypingImportsChecker
paths=./flake8_stripe
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ venv: $(VENV_NAME)/bin/activate
$(VENV_NAME)/bin/activate: setup.py
$(PIP) install --upgrade pip virtualenv
@test -d $(VENV_NAME) || $(PYTHON) -m virtualenv --clear $(VENV_NAME)
${VENV_NAME}/bin/python -m pip install -U pip tox twine pyright -c constraints.txt
${VENV_NAME}/bin/python -m pip install -r requirements.txt
@touch $(VENV_NAME)/bin/activate

test: venv
Expand All @@ -17,11 +17,9 @@ test-nomock: venv
@${VENV_NAME}/bin/tox -p auto -- --nomock $(TOX_ARGS)

ci-test: venv
${VENV_NAME}/bin/python -m pip install -U tox-gh-actions
@${VENV_NAME}/bin/tox $(TOX_ARGS)

coveralls: venv
${VENV_NAME}/bin/python -m pip install -U coveralls
@${VENV_NAME}/bin/tox -e coveralls

pyright: venv
Expand Down
2 changes: 0 additions & 2 deletions constraints.txt

This file was deleted.

15 changes: 0 additions & 15 deletions flake8_stripe/setup.py

This file was deleted.

2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
[tool.black]
line-length=79
target-version = [
"py27",
"py34",
"py35",
"py36",
"py37",
Expand Down
15 changes: 15 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# cryptography 40.0.0 deprecates support for Python 3.6 and PyPy3 < 7.3.10
cryptography<40
tox
twine
pyright <= 1.1.334
pytest-cov >= 2.8.1, < 2.11.0
pytest-mock >= 2.0.0
pytest-xdist >= 1.31.0
pytest >= 6.0.0
black==21.12b0
click==8.0.4 # Version 8.1 breaks black
flake8
coverage >= 4.5.3, < 5
coveralls
tox-gh-actions
4 changes: 2 additions & 2 deletions stripe/api_resources/list_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def next_page(
api_key=api_key,
stripe_version=stripe_version,
stripe_account=stripe_account,
**params_with_filters
**params_with_filters,
)
assert isinstance(result, ListObject)
return result
Expand Down Expand Up @@ -223,7 +223,7 @@ def previous_page(
api_key=api_key,
stripe_version=stripe_version,
stripe_account=stripe_account,
**params_with_filters
**params_with_filters,
)
assert isinstance(result, ListObject)
return result
2 changes: 1 addition & 1 deletion stripe/api_resources/search_result_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def next_search_result_page(
api_key=api_key,
stripe_version=stripe_version,
stripe_account=stripe_account,
**params_with_filters
**params_with_filters,
)
assert isinstance(result, SearchResultObject)
return result
2 changes: 1 addition & 1 deletion stripe/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(
def __str__(self):
msg = self._message or "<empty message>"
if self.request_id is not None:
return u"Request {0}: {1}".format(self.request_id, msg)
return "Request {0}: {1}".format(self.request_id, msg)
else:
return msg

Expand Down
2 changes: 1 addition & 1 deletion stripe/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def _request_internal(self, method, url, headers, post_data, is_streaming):
headers=headers,
data=post_data,
timeout=self._timeout,
**kwargs
**kwargs,
)
except TypeError as e:
raise TypeError(
Expand Down
4 changes: 2 additions & 2 deletions stripe/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ def fmt(key, val):
# key should already be a string
if re.search(r"\s", key):
key = repr(key)
return u"{key}={val}".format(key=key, val=val)
return "{key}={val}".format(key=key, val=val)

return u" ".join([fmt(key, val) for key, val in sorted(props.items())])
return " ".join([fmt(key, val) for key, val in sorted(props.items())])


# Borrowed from Django's source code
Expand Down
4 changes: 2 additions & 2 deletions tests/test_api_requestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class TestAPIRequestor(object):
},
"list": [1, "foo", "baz"],
"string": "boo",
"unicode": u"\u1234",
"unicode": "\u1234",
"datetime": datetime.datetime(2013, 1, 1, second=1, tzinfo=GMT1()),
"none": None,
}
Expand All @@ -204,7 +204,7 @@ class TestAPIRequestor(object):
],
"list": [("%s[0]", 1), ("%s[1]", "foo"), ("%s[2]", "baz")],
"string": [("%s", "boo")],
"unicode": [("%s", u"\u1234")],
"unicode": [("%s", "\u1234")],
"datetime": [("%s", 1356994801)],
"none": [],
}
Expand Down
14 changes: 7 additions & 7 deletions tests/test_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@

class TestStripeError(object):
def test_formatting(self):
err = error.StripeError(u"öre")
assert str(err) == u"öre"
err = error.StripeError("öre")
assert str(err) == "öre"

def test_formatting_with_request_id(self):
err = error.StripeError(u"öre", headers={"request-id": "123"})
assert str(err) == u"Request 123: öre"
err = error.StripeError("öre", headers={"request-id": "123"})
assert str(err) == "Request 123: öre"

def test_formatting_with_none(self):
err = error.StripeError(None, headers={"request-id": "123"})
assert str(err) == "Request 123: <empty message>"

def test_formatting_with_message_none_and_request_id_none(self):
err = error.StripeError(None)
assert str(err) == u"<empty message>"
assert str(err) == "<empty message>"

def test_repr(self):
err = error.StripeError(u"öre", headers={"request-id": "123"})
err = error.StripeError("öre", headers={"request-id": "123"})
assert (
repr(err) == "StripeError(message='öre', http_status=None, "
"request_id='123')"
Expand All @@ -44,7 +44,7 @@ def test_error_object_not_dict(self):
class TestStripeErrorWithParamCode(object):
def test_repr(self):
err = error.CardError(
u"öre",
"öre",
param="cparam",
code="ccode",
http_status=403,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_multipart_data_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TestMultipartDataGenerator(object):
def run_test_multipart_data_with_file(self, test_file):
params = {
"key1": b"ASCII value",
"key2": u"Üñìçôdé value",
"key2": "Üñìçôdé value",
"key3": test_file,
"key4": {
"string": "Hello!",
Expand Down Expand Up @@ -85,5 +85,5 @@ def test_multipart_data_stringio(self):

def test_multipart_data_unicode_file_name(self):
string = io.StringIO("foo")
string.name = u"паспорт.png"
string.name = "паспорт.png"
self.run_test_multipart_data_with_file(string)
8 changes: 4 additions & 4 deletions tests/test_stripe_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,14 @@ def check_invoice_data(self, data):
def test_repr(self):
obj = stripe.stripe_object.StripeObject("foo", "bar", myparam=5)

obj["object"] = u"\u4e00boo\u1f00"
obj["object"] = "\u4e00boo\u1f00"
obj.date = datetime.datetime.fromtimestamp(1511136000)

res = repr(obj)

assert u"<StripeObject \u4e00boo\u1f00" in res
assert u"id=foo" in res
assert u'"date": 1511136000' in res
assert "<StripeObject \u4e00boo\u1f00" in res
assert "id=foo" in res
assert '"date": 1511136000' in res

def test_pickling(self):
obj = stripe.stripe_object.StripeObject("foo", "bar", myparam=5)
Expand Down
19 changes: 3 additions & 16 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,8 @@ description = run the unit tests under {basepython}
setenv =
COVERAGE_FILE = {toxworkdir}/.coverage.{envname}
deps =
coverage >= 4.5.3, < 5 # TODO: upgrade to coverage 5 when we drop support for Python 3.4
py{310,39,38,37,36,35,py3}: pytest >= 6.0.0
py{34,27,py2}: pytest >= 4.6.2, < 4.7
pytest-cov >= 2.8.1, < 2.11.0
pytest-mock >= 2.0.0
pytest-xdist >= 1.31.0
-r requirements.txt

# ignore stripe directory as all tests are inside ./tests
commands = pytest --cov {posargs:-n auto} --ignore stripe
# compilation flags can be useful when prebuilt wheels cannot be used, e.g.
Expand All @@ -48,18 +44,12 @@ passenv = LDFLAGS,CFLAGS
[testenv:fmt]
description = run code formatting using black
basepython = python3.10
deps =
black==21.12b0
click==8.0.4 # Version 8.1 breaks black
commands = black . {posargs}
skip_install = true

[testenv:lint]
description = run static analysis and style check using flake8
basepython = python3.10
deps =
flake8
./flake8_stripe
commands =
python -m flake8 --show-source stripe tests setup.py
skip_install = true
Expand All @@ -70,10 +60,7 @@ skip_install = true
setenv =
COVERAGE_FILE = {toxworkdir}/.coverage
passenv = GITHUB_*
deps =
coverage >= 4.5.3, < 5 # TODO: upgrade to coverage 5 when we drop support for Python 3.4
coveralls
commands =
coverage combine
coveralls --service=github
depends = py{310,39,38,37,36,35,34,27,py3,py2}
depends = py{310,39,38,37,36,py3}

0 comments on commit dad14bb

Please sign in to comment.