[issue32896] Error when subclassing a dataclass with a field that uses a defaultfactory

2018-02-21 Thread John Didion

New submission from John Didion <johnp...@didion.net>:

> @dataclass
> class Foo:
>  x: dict = field(default_factory=dict)

> @dataclass
> class Bar(Foo):
>   y: int = 1

> @dataclass
> class Baz(Foo):
>   def blorf(self):
> print('hello')

> Foo().x
{}

> Bar().x
{}

> Baz().x

Traceback (most recent call last):
  File "", line 1, in 
TypeError: __init__() missing 1 required positional argument: 'x'

---

I understand that this is desired behavior when the subclass contains 
non-default attributes. But subclasses that define no additional attributes 
should work just the same as those that define only additional default 
attributes.

A similar issue was raised and dismissed when dataclasses was in development on 
GitHub: https://github.com/ericvsmith/dataclasses/issues/112, but that only 
concerned the case of subclasses defining non-default attributes.

--
messages: 312496
nosy: John Didion
priority: normal
severity: normal
status: open
title: Error when subclassing a dataclass with a field that uses a 
defaultfactory
type: crash
versions: Python 3.7

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32896>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28063] Adding a mutually exclusive group to an argument group results in segmentation fault under linux

2016-09-10 Thread John Didion

John Didion added the comment:

I can't reproduce it with 3.5.2 on SL6 either. So it must be a weird issue 
specific to whatever environment they're using for builds on Travis. I'll close 
this and submit it as a bug over there.

--
resolution:  -> works for me
status: open -> closed

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28063>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28063] Adding a mutually exclusive group to an argument group results in segmentation fault under linux

2016-09-10 Thread John Didion

John Didion added the comment:

This code also works fine when I run it myself on python 3.5.1 on an SL6 
machine, so it's either specific to 3.5.2 or it's very platform-specific.

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28063>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28063] Adding a mutually exclusive group to an argument group results in segmentation fault under linux

2016-09-10 Thread John Didion

New submission from John Didion:

The following code works fine when I run it on OSX 10.9, but causes a 
segmentation fault when run on linux. Specifically, the Travis build on python 
3.5.2 results in a segfault when the last line is uncommented.

import argparse
parser = argparse.ArgumentParser()
group = parser.add_argument_group("Colorspace options")
group.add_mutually_exclusive_group()

--
messages: 275645
nosy: John.Didion
priority: normal
severity: normal
status: open
title: Adding a mutually exclusive group to an argument group results in 
segmentation fault under linux
type: crash
versions: Python 3.5

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28063>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11588] Add necessarily inclusive groups to argparse

2011-03-17 Thread John Didion

New submission from John Didion johndid...@gmail.com:

Just as some options are mutually exclusive, there are others that are 
necessarily inclusive, i.e. all or nothing. I propose the addition of 
ArgumentParser.add_necessarily_inclusive_group(required=True).

This also means that argparse will need to support nested groups. For example, 
if I want to set up options such that the user has to provide an output file OR 
(an output directory AND (an output file pattern OR an output file extension)):

output_group = parser.add_mutually_exclusive_group(required=True)
output_group.add_argument(-o, --outfile)
outdir_group = output_group.add_necessarily_inclusive_group()
outdir_group.add_argument(-O, --outdir)
outfile_group = outdir_group.add_mutually_exclusive_group(required=True)
outfile_group.add_argument(-p, --outpattern)
outfile_group.add_argument(-s, --outsuffix)

The usage should then look like:

(-o FILE | (-O DIR  (-p PATTERN | -s SUFFIX))

--
messages: 131262
nosy: John.Didion
priority: normal
severity: normal
status: open
title: Add necessarily inclusive groups to argparse
type: feature request
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11588
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com