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
Closed

UnboundLocalError when combining allow_dash and dir_okay #551

DRMacIver opened this issue Apr 4, 2016 · 4 comments
Assignees
Labels

Comments

@DRMacIver
Copy link

@DRMacIver DRMacIver 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
Copy link
Member

@untitaker untitaker commented Apr 4, 2016

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

@DRMacIver
Copy link
Author

@DRMacIver DRMacIver commented Apr 4, 2016

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

@DRMacIver
Copy link
Author

@DRMacIver DRMacIver commented Apr 4, 2016

And thanks for fixing it :-)

@untitaker
Copy link
Member

@untitaker untitaker commented Apr 4, 2016

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

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants