New GitHub issue #119375 from e-kwsm:<br>

<hr>

<pre>
# Bug report

### Bug description:

```python
import argparse

p = argparse.ArgumentParser()
p.add_argument("--foo", action=argparse.BooleanOptionalAction)
print(p.parse_args(["--foo", "--no-foo"]))  # Namespace(foo=False)
print(p.parse_args(["--no-foo", "--foo"]))  # Namespace(foo=True)
```

Here `BooleanOptionalAction` is used, but the options, `--foo` and `--no-foo`, are *not* mutually exclusive, and the last one becomes effective without warning.

OTOH the below code

```python
import argparse

p = argparse.ArgumentParser()
g = p.add_mutually_exclusive_group()
g.add_argument("--foo", action="store_true")
g.add_argument("--no-foo", action="store_true")
p.parse_args(["--foo", "--no-foo"])
```

raises error:

```
usage: [-h] [--foo | --no-foo]
: error: argument --no-foo: not allowed with argument --foo
```

### CPython versions tested on:

3.12

### Operating systems tested on:

Linux
</pre>

<hr>

<a href="https://github.com/python/cpython/issues/119375">View on GitHub</a>
<p>Labels: type-bug</p>
<p>Assignee: </p>