Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't require a function named f #5698

Closed
porterjamesj opened this issue Apr 22, 2014 · 1 comment · Fixed by #5699
Closed

can't require a function named f #5698

porterjamesj opened this issue Apr 22, 2014 · 1 comment · Fixed by #5699
Milestone

Comments

@porterjamesj
Copy link
Contributor

It took me a while to figure this one out:

def f(x):
    return(x)

@require(f):
def g(y):
    return f(y)

gives:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-86-98a37b0c736a> in <module>()
----> 1 @require(f)
      2 def g(y):
      3     return f(y)
      4

/usr/local/lib/python2.7/dist-packages/IPython/parallel/controller/dependency.pyc in require(*objects, **mapping)
    133     for name, obj in mapping.items():
    134         mapping[name] = can(obj)
--> 135     return depend(_require, *names, **mapping)
    136
    137 class Dependency(set):

TypeError: __init__() got multiple values for keyword argument 'f'

I believe the cause is the use of f as a name in the constructor here.

This seems like a bit of an arbitrary restriction; it may not be possible to get around having to forbid the use of some function name, but at least we could maybe use something less likely to collide with users' things (_f maybe?).

@minrk
Copy link
Member

minrk commented Apr 22, 2014

yeah, poor choice of argument names. I'll make it something less likely to collide.

@minrk minrk added this to the 3.0 milestone Apr 22, 2014
@minrk minrk modified the milestones: 2.1, 3.0 Apr 22, 2014
takluyver added a commit that referenced this issue May 7, 2014
causes kwarg collisions if the depended-upon function has the same name.

closes #5698
takluyver added a commit that referenced this issue May 7, 2014
causes kwarg collisions if the depended-upon function has the same name.

closes #5698
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants