Skip to content

Commit

Permalink
Merge b115a66 into c5248c8
Browse files Browse the repository at this point in the history
  • Loading branch information
eriknw committed Sep 9, 2020
2 parents c5248c8 + b115a66 commit a90d40b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ os: linux
dist: xenial

python:
- 3.6
- 3.7
- 3.8
- "3.9-dev"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Innerscope

[![Python Version](https://img.shields.io/badge/python-3.7%20%7C%203.8%20%7C%203.9-blue)](https://img.shields.io/badge/python-3.7%20%7C%203.8%20%7C%203.9-blue)
[![Python Version](https://img.shields.io/badge/python-3.6%20%7C%203.7%20%7C%203.8%20%7C%203.9-blue)](https://img.shields.io/badge/python-3.6%20%7C%203.7%20%7C%203.8%20%7C%203.9-blue)
[![Version](https://img.shields.io/pypi/v/innerscope.svg)](https://pypi.org/project/innerscope/)
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://github.com/eriknw/innerscope/blob/master/LICENSE)
[![Build Status](https://travis-ci.org/eriknw/innerscope.svg?branch=master)](https://travis-ci.org/eriknw/innerscope)
Expand Down
10 changes: 8 additions & 2 deletions innerscope/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def bindto(self, func, *, use_closures=None, use_globals=None):
use_globals = self.scoped_function.use_globals
return ScopedFunction(func, self, use_closures=use_closures, use_globals=use_globals)

def call(self, func, *args, **kwargs):
def call(self, *func_and_args, **kwargs):
"""Bind the variables of this object to a function and call the function.
>>> @call
Expand Down Expand Up @@ -228,6 +228,9 @@ def call(self, func, *args, **kwargs):
Scope.bindto
Scope.callwith
"""
if not func_and_args:
raise TypeError("scope.call() missing 1 required positional argument: 'func'")
func, *args = func_and_args
return self.bindto(func)(*args, **kwargs)

def callwith(self, *args, **kwargs):
Expand Down Expand Up @@ -663,7 +666,7 @@ def bindwith_inner(func, *, use_closures=True, use_globals=True):
return bindwith_inner


def call(func, *args, **kwargs):
def call(*func_and_args, **kwargs):
"""Useful for making simple pipelines to go from functions to scopes.
>>> @call
Expand Down Expand Up @@ -700,6 +703,9 @@ def call(func, *args, **kwargs):
--------
callwith
"""
if not func_and_args:
raise TypeError("call() missing 1 required positional argument: 'func'")
func, *args = func_and_args
scoped = ScopedFunction(func)
return scoped(*args, **kwargs)

Expand Down
5 changes: 5 additions & 0 deletions innerscope/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ def check(scope2):
check(scope1.call(f2))
check(scope1.callwith()(f2))

with raises(TypeError, match="missing 1 required positional"):
scope1.call()
with raises(TypeError, match="missing 1 required positional"):
innerscope.call()


def test_with_args():
def f1(a):
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
url="https://github.com/eriknw/innerscope",
packages=find_packages(),
license="BSD",
python_requires=">=3.7",
python_requires=">=3.6",
setup_requires=[],
install_requires=["toolz"],
tests_require=["pytest"],
Expand All @@ -27,6 +27,7 @@
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3 :: Only",
Expand Down

0 comments on commit a90d40b

Please sign in to comment.