black: AttributeError: 'int' object has no attribute 'lower'

Describe the bug When I try to run black on a file I get this error. even a simple file that has only print('hello world') I am runnning black temp.py

To Reproduce Steps to reproduce the behavior: black temp.py

Environment (please complete the following information): python 3.8 macos black.version ‘19.10b0’ click.version ‘7.1.2’

Error

(venv) $ black temp.py Traceback (most recent call last): File "/venv/bin/black", line 10, in <module> sys.exit(patched_main()) File "/venv/lib/python3.8/site-packages/black.py", line 4135, in patched_main main() File "/venv/lib/python3.8/site-packages/click/core.py", line 829, in __call__ return self.main(*args, **kwargs) File "/venv/lib/python3.8/site-packages/click/core.py", line 781, in main with self.make_context(prog_name, args, **extra) as ctx: File "/venv/lib/python3.8/site-packages/click/core.py", line 700, in make_context self.parse_args(ctx, args) File "/venv/lib/python3.8/site-packages/click/core.py", line 1048, in parse_args value, args = param.handle_parse_result(ctx, opts, args) File "/venv/lib/python3.8/site-packages/click/core.py", line 1623, in handle_parse_result value = self.full_process_value(ctx, value) File "/venv/lib/python3.8/site-packages/click/core.py", line 1965, in full_process_value return Parameter.full_process_value(self, ctx, value) File "/venv/lib/python3.8/site-packages/click/core.py", line 1589, in full_process_value value = self.process_value(ctx, value) File "/venv/lib/python3.8/site-packages/click/core.py", line 1579, in process_value return self.type_cast_value(ctx, value) File "/venv/lib/python3.8/site-packages/click/core.py", line 1568, in type_cast_value return _convert(value, (self.nargs != 1) + bool(self.multiple)) File "/venv/lib/python3.8/site-packages/click/core.py", line 1565, in _convert return self.type(value, self, ctx) File "/venv/lib/python3.8/site-packages/click/types.py", line 46, in __call__ return self.convert(value, param, ctx) File "/venv/lib/python3.8/site-packages/click/types.py", line 412, in convert value = value.lower() AttributeError: 'int' object has no attribute 'lower'

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 19 (4 by maintainers)

Most upvoted comments

@SanketDG , @ichard26

  • My issue is fixed and you see/found the problem.

  • The hint to use --verbose was a good one.

  • IMO some way to catch the error as a configuration problem would be helpful.

  • IMO black should always show if a configuration file is being used as part of its run message.

Thanks for the help I will leave this to you.

@SanketDG thanks for the info! What’s interesting is that they accept "1" but not 1, which I guess is reasonable since all input from the command line are strings. I do agree with you that a error message should be outputted then an hard to protect AttributeError happening. Since its happening in the Click core, we would have to try and except the main() call which isn’t ideal. We could just verify the types in the Black TOML logic, but that isn’t ideal too.

Although this isn’t exactly welcoming promising for an issue 😃

That sounds like an issue with how they’re using Click, not with Click. 😉