[issue46637] Incorrect error message: "missing 1 required positional argument"

2022-02-04 Thread Alex Waygood


Change by Alex Waygood :


--
nosy: +AlexWaygood

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46637] Incorrect error message: "missing 1 required positional argument"

2022-02-04 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I think the incorrect qualification should be dropped, if sanely feasible.

More misleading are hidden positional-only args.  Doc:
  min(iterable, *[, key, default])
  min(arg1, arg2, *args[, key])

>>> min(iterator=(1,3))
Traceback (most recent call last):
  File "", line 1, in 
min(iterator=(1,3))
TypeError: min expected at least 1 argument, got 0

1 was passed, but 0 were gotten, as the 1 passed was silently ignored.

--
nosy: +terry.reedy
versions: +Python 3.11 -Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46637] Incorrect error message: "missing 1 required positional argument"

2022-02-04 Thread Andre Roberge


Change by Andre Roberge :


--
nosy: +aroberge

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46637] Incorrect error message: "missing 1 required positional argument"

2022-02-04 Thread Anders Hovmöller

Anders Hovmöller  added the comment:

For `foo(a, /, b)`, it could be:

"TypeError: foo() missing 1 required argument 'a', and one required positional 
argument 'b'.

If we start on this road there are some more, like for `def foo(a, *, b)` you 
get the error "TypeError: foo() missing 1 required positional argument: 'a'" 
which leaves out that the keyword only argument is also required. 

Another solution would be something like:

TypeError: foo() missing 3 required arguments: 'a' (positional only), 'b', 'c' 
(keyword only)

This solution scales to the worst complex cases, and is a lot clearer imo. 
Could even be further improved with some nicer formatting:

TypeError: foo() missing 3 required arguments: 
'a' (positional only)
'b'
'c' (keyword only)

But that might be a bit overkill :)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46637] Incorrect error message: "missing 1 required positional argument"

2022-02-04 Thread Eric V. Smith


Eric V. Smith  added the comment:

Given this current behavior:

>>> def foo(a, /, b): pass
...
>>> foo()
Traceback (most recent call last):
  File "", line 1, in 
TypeError: foo() missing 2 required positional arguments: 'a' and 'b'

What would you suggest?

I agree the current messages aren't perfect.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46637] Incorrect error message: "missing 1 required positional argument"

2022-02-04 Thread Anders Hovmöller

Anders Hovmöller  added the comment:

Just dropping the word "positional" is very good. That word is a lie, and just 
removing it makes it true.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46637] Incorrect error message: "missing 1 required positional argument"

2022-02-04 Thread Eric V. Smith


Eric V. Smith  added the comment:

I guess the technically correct term is positional-or-keyword, but that seems 
like too much: https://docs.python.org/3/glossary.html

I think dropping "positional" doesn't increase the precision of the error 
message, but I'll admit I can't think of anything better. And lacking something 
better I don't think we should change this.

--
nosy: +eric.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46637] Incorrect error message: "missing 1 required positional argument"

2022-02-04 Thread Anders Hovmöller

New submission from Anders Hovmöller :

>>> def foo(a):
... pass
... 
>>> foo()
Traceback (most recent call last):
  File "", line 1, in 
TypeError: foo() missing 1 required positional argument: 'a'

This error is incorrect. It says "positional argument", but it's just 
"argument". The proof is that if you call it with

foo(a=3)

it works fine.

--
components: Interpreter Core
messages: 412510
nosy: Anders.Hovmöller
priority: normal
severity: normal
status: open
title: Incorrect error message: "missing 1 required positional argument"
type: enhancement
versions: Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com