Skip to content

Commit

Permalink
Fix typos.
Browse files Browse the repository at this point in the history
  • Loading branch information
dgilland committed Sep 28, 2021
1 parent fb72d4a commit f0ac168
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 53 deletions.
6 changes: 3 additions & 3 deletions src/pydash/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ def __init__(self, func, wait, max_wait=False):

def __call__(self, *args, **kwargs):
"""
Execute :attr:`func` if function hasn't been called witinin last :attr:`wait` milliseconds
or in last :attr:`max_wait` milliseconds.
Execute :attr:`func` if function hasn't been called within last :attr:`wait` milliseconds or
in last :attr:`max_wait` milliseconds.
Return results of last successful call.
"""
Expand Down Expand Up @@ -386,7 +386,7 @@ def __init__(self, func, wait):

def __call__(self, *args, **kwargs):
"""
Execute :attr:`func` if function hasn't been called witinin last :attr:`wait` milliseconds.
Execute :attr:`func` if function hasn't been called within last :attr:`wait` milliseconds.
Return results of last successful call.
"""
Expand Down
2 changes: 1 addition & 1 deletion src/pydash/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def getargcount(iteratee, maxargs):
"""Return argument count of iteratee function."""
if hasattr(iteratee, "_argcount"):
# Optimization feature where argcount of iteratee is known and properly
# set by initator.
# set by initiator.
return iteratee._argcount

if isinstance(iteratee, type) or pyd.is_builtin(iteratee):
Expand Down
2 changes: 1 addition & 1 deletion src/pydash/numerical.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Numerical/mathemetical related functions.
Numerical/mathematical related functions.
.. versionadded:: 2.1.0
"""
Expand Down
2 changes: 1 addition & 1 deletion src/pydash/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ def parse_int(value, radix=None):
"""
if not radix and pyd.is_string(value):
try:
# Check if value is hexadcimal and if so use base-16 conversion.
# Check if value is hexadecimal and if so use base-16 conversion.
int(value, 16)
except ValueError:
pass
Expand Down
2 changes: 1 addition & 1 deletion src/pydash/predicates.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ def is_equal_with(value, other, customizer):
.. versionadded:: 4.0.0
"""
# If customizer provided, use it for comparision.
# If customizer provided, use it for comparison.
equal = customizer(value, other) if callable(customizer) else None

# Return customizer results if anything but None.
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def reduce_right_iteratee0(a, b):
return a + b


def noop(*args, **kargs):
def noop(*args, **kwargs):
pass


Expand Down
8 changes: 4 additions & 4 deletions tests/test_arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,8 @@ def test_sorted_index(case, expected):
(
(
["twenty", "thirty", "fifty"],
"fourty",
lambda x: {"twenty": 20, "thirty": 30, "fourty": 40, "fifty": 50}[x],
"forty",
lambda x: {"twenty": 20, "thirty": 30, "forty": 40, "fifty": 50}[x],
),
2,
),
Expand Down Expand Up @@ -623,8 +623,8 @@ def test_sorted_last_index(case, expected):
(
(
["twenty", "thirty", "fifty"],
"fourty",
lambda x: {"twenty": 20, "thirty": 30, "fourty": 40, "fifty": 50}[x],
"forty",
lambda x: {"twenty": 20, "thirty": 30, "forty": 40, "fifty": 50}[x],
),
2,
),
Expand Down
37 changes: 19 additions & 18 deletions tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_after(case, expected):


@parametrize(
"case,args,kargs,expected",
"case,args,kwargs,expected",
[
((lambda a=0, b=0, c=0, d=0: a + b + c + d, 1), (1, 2, 3, 4), {}, 1),
((lambda a=0, b=0, c=0, d=0: a + b + c + d, 2), (1, 2, 3, 4), {}, 3),
Expand All @@ -45,8 +45,8 @@ def test_after(case, expected):
((lambda a=0, b=0, c=0, d=0: a + b + c + d, None), (1, 2, 3, 4), {}, 10),
],
)
def test_ary(case, args, kargs, expected):
assert _.ary(*case)(*args, **kargs) == expected
def test_ary(case, args, kwargs, expected):
assert _.ary(*case)(*args, **kwargs) == expected


@parametrize(
Expand Down Expand Up @@ -181,11 +181,12 @@ def func():


@parametrize(
"func,wait,args,kargs,expected", [(lambda a, b, c: (a, b, c), 250, (1, 2), {"c": 3}, (1, 2, 3))]
"func,wait,args,kwargs,expected",
[(lambda a, b, c: (a, b, c), 250, (1, 2), {"c": 3}, (1, 2, 3))],
)
def test_delay(func, wait, args, kargs, expected):
def test_delay(func, wait, args, kwargs, expected):
start = time.time() * 1000
result = _.delay(func, wait, *args, **kargs)
result = _.delay(func, wait, *args, **kwargs)
stop = time.time() * 1000

assert (wait - 10) <= (stop - start) <= (wait + 10)
Expand Down Expand Up @@ -297,14 +298,14 @@ def test_over_args(func, transforms, args, expected):


@parametrize(
"case,case_args,case_kargs,args,expected",
"case,case_args,case_kwargs,args,expected",
[
(lambda a, b, c: a + b + c, ("a", "b"), {}, ("c",), "abc"),
(lambda a, b, c: a + b + c, ("a",), {"c": "d"}, ("b",), "abd"),
],
)
def test_partial(case, case_args, case_kargs, args, expected):
assert _.partial(case, *case_args, **case_kargs)(*args) == expected
def test_partial(case, case_args, case_kwargs, args, expected):
assert _.partial(case, *case_args, **case_kwargs)(*args) == expected


def test_partial_as_iteratee():
Expand All @@ -315,18 +316,18 @@ def test_partial_as_iteratee():


@parametrize(
"case,case_args,case_kargs,args,expected",
"case,case_args,case_kwargs,args,expected",
[
(lambda a, b, c: a + b + c, ("a", "b"), {}, ("c",), "cab"),
(lambda a, b, c: a + b + c, ("a",), {"c": "d"}, ("b",), "bad"),
],
)
def test_partial_right(case, case_args, case_kargs, args, expected):
assert _.partial_right(case, *case_args, **case_kargs)(*args) == expected
def test_partial_right(case, case_args, case_kwargs, args, expected):
assert _.partial_right(case, *case_args, **case_kwargs)(*args) == expected


@parametrize(
"case,args,kargs,expected",
"case,args,kwargs,expected",
[
((lambda a, b, c: [a, b, c], 2, 0, 1), ("b", "c", "a"), {}, ["a", "b", "c"]),
((lambda a, b, c: [a, b, c], [2, 0, 1]), ("b", "c", "a"), {}, ["a", "b", "c"]),
Expand All @@ -335,8 +336,8 @@ def test_partial_right(case, case_args, case_kargs, args, expected):
((lambda a, b, c: [a, b, c], 3, 2, 0, 1), ("b", "c", "a"), {}, ["a", "b", "c"]),
],
)
def test_rearg(case, args, kargs, expected):
assert _.rearg(*case)(*args, **kargs) == expected
def test_rearg(case, args, kwargs, expected):
assert _.rearg(*case)(*args, **kwargs) == expected


@parametrize(
Expand Down Expand Up @@ -374,14 +375,14 @@ def func():


@parametrize(
"case,args,kargs,expected",
"case,args,kwargs,expected",
[
(lambda a=0, b=0, c=0, d=0: a + b + c + d, (1, 2, 3, 4), {}, 1),
(lambda a=0, b=0, c=0, d=0: a + b + c + d, (1, 2, 3, 4), {"d": 10}, 11),
],
)
def test_unary(case, args, kargs, expected):
assert _.unary(case)(*args, **kargs) == expected
def test_unary(case, args, kwargs, expected):
assert _.unary(case)(*args, **kwargs) == expected


@parametrize(
Expand Down
26 changes: 13 additions & 13 deletions tests/test_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1165,37 +1165,37 @@ def test_upper_first(case, expected):
@parametrize(
"case,expected",
[
({"args": [""], "kargs": {}}, ""),
({"args": ["/"], "kargs": {}}, "/"),
({"args": ["http://github.com"], "kargs": {}}, "http://github.com"),
({"args": ["http://github.com:80"], "kargs": {}}, "http://github.com:80"),
({"args": [""], "kwargs": {}}, ""),
({"args": ["/"], "kwargs": {}}, "/"),
({"args": ["http://github.com"], "kwargs": {}}, "http://github.com"),
({"args": ["http://github.com:80"], "kwargs": {}}, "http://github.com:80"),
(
{"args": ["http://github.com:80", "pydash", "issues/"], "kargs": {}},
{"args": ["http://github.com:80", "pydash", "issues/"], "kwargs": {}},
"http://github.com:80/pydash/issues/",
),
({"args": ["/foo", "bar", "/baz", "/qux/"], "kargs": {}}, "/foo/bar/baz/qux/"),
({"args": ["/foo/bar"], "kargs": {"a": 1, "b": "two"}}, "/foo/bar?a=1&b=two"),
({"args": ["/foo/bar?x=5"], "kargs": {"a": 1, "b": "two"}}, "/foo/bar?x=5&a=1&b=two"),
({"args": ["/foo", "bar", "/baz", "/qux/"], "kwargs": {}}, "/foo/bar/baz/qux/"),
({"args": ["/foo/bar"], "kwargs": {"a": 1, "b": "two"}}, "/foo/bar?a=1&b=two"),
({"args": ["/foo/bar?x=5"], "kwargs": {"a": 1, "b": "two"}}, "/foo/bar?x=5&a=1&b=two"),
(
{"args": ["/foo/bar?x=5", "baz?z=3"], "kargs": {"a": 1, "b": "two"}},
{"args": ["/foo/bar?x=5", "baz?z=3"], "kwargs": {"a": 1, "b": "two"}},
"/foo/bar/baz?x=5&a=1&b=two&z=3",
),
(
{"args": ["/foo/bar?x=5", "baz?z=3"], "kargs": {"a": [1, 2], "b": "two"}},
{"args": ["/foo/bar?x=5", "baz?z=3"], "kwargs": {"a": [1, 2], "b": "two"}},
"/foo/bar/baz?x=5&a=1&a=2&b=two&z=3",
),
(
{"args": ["/foo#bar", "baz"], "kargs": {"a": [1, 2], "b": "two"}},
{"args": ["/foo#bar", "baz"], "kwargs": {"a": [1, 2], "b": "two"}},
"/foo?a=1&a=2&b=two#bar/baz",
),
(
{"args": ["/foo", "baz#bar"], "kargs": {"a": [1, 2], "b": "two"}},
{"args": ["/foo", "baz#bar"], "kwargs": {"a": [1, 2], "b": "two"}},
"/foo/baz?a=1&a=2&b=two#bar",
),
],
)
def test_url(case, expected):
result = _.url(*case["args"], **case["kargs"])
result = _.url(*case["args"], **case["kwargs"])

r_scheme, r_netloc, r_path, r_query, r_fragment = urlsplit(result)
e_scheme, e_netloc, e_path, e_query, e_fragment = urlsplit(expected)
Expand Down
20 changes: 10 additions & 10 deletions tests/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,24 +215,24 @@ def test_matches_property(case, arg, expected):


@parametrize(
"case,args,kargs,key",
"case,args,kwargs,key",
[
((lambda a, b: a + b,), (1, 2), {}, "(1, 2){}"),
((lambda a, b: a + b,), (1,), {"b": 2}, "(1,){'b': 2}"),
((lambda a, b: a + b, lambda a, b: a * b), (1, 2), {}, 2),
((lambda a, b: a + b, lambda a, b: a * b), (1,), {"b": 2}, 2),
],
)
def test_memoize(case, args, kargs, key):
def test_memoize(case, args, kwargs, key):
memoized = _.memoize(*case)
expected = case[0](*args, **kargs)
assert memoized(*args, **kargs) == expected
expected = case[0](*args, **kwargs)
assert memoized(*args, **kwargs) == expected
assert memoized.cache
assert memoized.cache[key] == expected


@parametrize(
"case,args,kargs,expected",
"case,args,kwargs,expected",
[
(("a.b",), ({"a": {"b": lambda x, y: x + y}}, 1, 2), {}, 3),
(
Expand All @@ -255,12 +255,12 @@ def test_memoize(case, args, kargs, key):
),
],
)
def test_method(case, args, kargs, expected):
assert _.method(*case)(*args, **kargs) == expected
def test_method(case, args, kwargs, expected):
assert _.method(*case)(*args, **kwargs) == expected


@parametrize(
"case,args,kargs,expected",
"case,args,kwargs,expected",
[
(({"a": {"b": lambda x, y: x + y}},), ("a.b", 1, 2), {}, 3),
(
Expand All @@ -274,8 +274,8 @@ def test_method(case, args, kargs, expected):
),
],
)
def test_method_of(case, args, kargs, expected):
assert _.method_of(*case)(*args, **kargs) == expected
def test_method_of(case, args, kwargs, expected):
assert _.method_of(*case)(*args, **kwargs) == expected


@parametrize("case,expected", [((), None), ((1, 2, 3), None)])
Expand Down

0 comments on commit f0ac168

Please sign in to comment.