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

UnboundLocalError when combining allow_dash and dir_okay #551

Closed
DRMacIver opened this issue Apr 4, 2016 · 4 comments

Comments

@DRMacIver
Copy link

commented Apr 4, 2016

import click

@click.command()
@click.argument('filename', type=click.Path(dir_okay=False, allow_dash=True))
def foo(filename):
    pass

if __name__ == '__main__':
    foo()

When this script is invoked with the argument '-' I see the following error:

  File "boo.py", line 10, in <module>
    foo()
  File "/home/david/projects/structureshrink/foo/lib/python3.5/site-packages/click-6.4-py3.5.egg/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/home/david/projects/structureshrink/foo/lib/python3.5/site-packages/click-6.4-py3.5.egg/click/core.py", line 695, in main
    with self.make_context(prog_name, args, **extra) as ctx:
  File "/home/david/projects/structureshrink/foo/lib/python3.5/site-packages/click-6.4-py3.5.egg/click/core.py", line 620, in make_context
    self.parse_args(ctx, args)
  File "/home/david/projects/structureshrink/foo/lib/python3.5/site-packages/click-6.4-py3.5.egg/click/core.py", line 874, in parse_args
    value, args = param.handle_parse_result(ctx, opts, args)
  File "/home/david/projects/structureshrink/foo/lib/python3.5/site-packages/click-6.4-py3.5.egg/click/core.py", line 1390, in handle_parse_result
    value = self.full_process_value(ctx, value)
  File "/home/david/projects/structureshrink/foo/lib/python3.5/site-packages/click-6.4-py3.5.egg/click/core.py", line 1359, in full_process_value
    value = self.process_value(ctx, value)
  File "/home/david/projects/structureshrink/foo/lib/python3.5/site-packages/click-6.4-py3.5.egg/click/core.py", line 1349, in process_value
    return self.type_cast_value(ctx, value)
  File "/home/david/projects/structureshrink/foo/lib/python3.5/site-packages/click-6.4-py3.5.egg/click/core.py", line 1338, in type_cast_value
    return _convert(value, (self.nargs != 1) + bool(self.multiple))
  File "/home/david/projects/structureshrink/foo/lib/python3.5/site-packages/click-6.4-py3.5.egg/click/core.py", line 1336, in _convert
    return self.type(value, self, ctx)
  File "/home/david/projects/structureshrink/foo/lib/python3.5/site-packages/click-6.4-py3.5.egg/click/types.py", line 38, in __call__
    return self.convert(value, param, ctx)
  File "/home/david/projects/structureshrink/foo/lib/python3.5/site-packages/click-6.4-py3.5.egg/click/types.py", line 426, in convert
    if not self.dir_okay and stat.S_ISDIR(st.st_mode):

I am running Python 3.5.1 and using click version 6.4.

untitaker added a commit that referenced this issue Apr 4, 2016
Fix #551
untitaker added a commit that referenced this issue Apr 4, 2016
Fix #551
@untitaker untitaker self-assigned this Apr 4, 2016
@untitaker untitaker closed this in fab5356 Apr 4, 2016
@untitaker untitaker removed the in progress label Apr 4, 2016
@untitaker

This comment has been minimized.

Copy link
Member

commented Apr 4, 2016

Thanks, I've fixed this. Do you need a bugfix release?

@DRMacIver

This comment has been minimized.

Copy link
Author

commented Apr 4, 2016

It would be useful but isn't super high priority. Up to you.

@DRMacIver

This comment has been minimized.

Copy link
Author

commented Apr 4, 2016

And thanks for fixing it :-)

@untitaker

This comment has been minimized.

Copy link
Member

commented Apr 4, 2016

Nice, PyPI returned a 500 while uploading. We're now on 6.6 instead of 6.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.