[issue43532] Add keyword-only fields to dataclasses

2022-02-09 Thread Eric V. Smith


Eric V. Smith  added the comment:

Thanks, Henry Schreiner!

--
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue43532] Add keyword-only fields to dataclasses

2022-02-09 Thread miss-islington


miss-islington  added the comment:


New changeset 7445949a4399ab19fbdd5a0b0aca53a690c3251b by Miss Islington (bot) 
in branch '3.10':
bpo-43532: add version added to KW_ONLY (GH-31235)
https://github.com/python/cpython/commit/7445949a4399ab19fbdd5a0b0aca53a690c3251b


--

___
Python tracker 

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



[issue43532] Add keyword-only fields to dataclasses

2022-02-09 Thread miss-islington


Change by miss-islington :


--
pull_requests: +29406
pull_request: https://github.com/python/cpython/pull/31236

___
Python tracker 

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



[issue43532] Add keyword-only fields to dataclasses

2022-02-09 Thread miss-islington


miss-islington  added the comment:


New changeset 5a3f97291eea96037cceee097ebc00bba44bc9ed by Henry Schreiner in 
branch 'main':
bpo-43532: add version added to KW_ONLY (GH-31235)
https://github.com/python/cpython/commit/5a3f97291eea96037cceee097ebc00bba44bc9ed


--
nosy: +miss-islington

___
Python tracker 

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



[issue43532] Add keyword-only fields to dataclasses

2022-02-09 Thread Henry Schreiner


Change by Henry Schreiner :


--
nosy: +Henry Schreiner
nosy_count: 9.0 -> 10.0
pull_requests: +29405
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/31235

___
Python tracker 

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



[issue43532] Add keyword-only fields to dataclasses

2021-10-21 Thread Finite State Machine


Finite State Machine  added the comment:

I doubt it's worth opening a separate issue for this, so I'll mention it here:

In the documentation 
(https://docs.python.org/3.10/library/dataclasses.html#dataclasses.KW_ONLY) 
nothing documents KW_ONLY as being new in Python 3.10.

--
nosy: +finite-state-machine

___
Python tracker 

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



[issue43532] Add keyword-only fields to dataclasses

2021-08-08 Thread Marc Mueller


Change by Marc Mueller :


--
nosy: +cdce8p

___
Python tracker 

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



[issue43532] Add keyword-only fields to dataclasses

2021-08-03 Thread jack1142


jack1142  added the comment:

Does this change deserve an entry in the What's New in Python document in 
addition to the changelog entry?

--

___
Python tracker 

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



[issue43532] Add keyword-only fields to dataclasses

2021-04-27 Thread Eric V. Smith


Eric V. Smith  added the comment:

> Will this close https://bugs.python.org/issue36077 ?

No, not directly, although I'm going to close that issue as "won't fix".

But you can specify that the child class requires all params as kw_only. 
Continuing the example:

>>> @dataclass(kw_only=True)
... class Child(Parent):
...   y: int
...
>>> Child(0, y=1)
Child(x=0, y=1)

--

___
Python tracker 

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



[issue43532] Add keyword-only fields to dataclasses

2021-04-26 Thread Laurie Opperman


Laurie Opperman  added the comment:

Will this close https://bugs.python.org/issue36077 ?

--
nosy: +Epic_Wink

___
Python tracker 

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



[issue43532] Add keyword-only fields to dataclasses

2021-04-26 Thread Eric V. Smith


Eric V. Smith  added the comment:

I've checked in the code, tests, and some basic documentation. I didn't finish 
the documentation in order to make sure I could get this in before beta 1. I'm 
going to leave this issue open until I have time for the rest of the 
documentation.

--
resolution:  -> fixed
stage: patch review -> 

___
Python tracker 

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



[issue43532] Add keyword-only fields to dataclasses

2021-04-25 Thread Eric V. Smith


Change by Eric V. Smith :


--
pull_requests: +24320
pull_request: https://github.com/python/cpython/pull/25608

___
Python tracker 

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



[issue43532] Add keyword-only fields to dataclasses

2021-03-17 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

+1 for this idea.  I don't see any downside.

--
nosy: +rhettinger

___
Python tracker 

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



[issue43532] Add keyword-only fields to dataclasses

2021-03-17 Thread jack1142


Change by jack1142 :


--
nosy: +jack1142

___
Python tracker 

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



[issue43532] Add keyword-only fields to dataclasses

2021-03-17 Thread Eric V. Smith


Change by Eric V. Smith :


--
keywords: +patch
pull_requests: +23671
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24909

___
Python tracker 

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



[issue43532] Add keyword-only fields to dataclasses

2021-03-17 Thread Ryan Hiebert


Change by Ryan Hiebert :


--
nosy: +ryanhiebert

___
Python tracker 

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



[issue43532] Add keyword-only fields to dataclasses

2021-03-17 Thread Kamil Turek


Change by Kamil Turek :


--
nosy: +kamilturek

___
Python tracker 

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



[issue43532] Add keyword-only fields to dataclasses

2021-03-17 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

This looks like a duplicate of https://bugs.python.org/issue33129 or that 
ticket can be closed.

--
nosy: +xtreak

___
Python tracker 

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



[issue43532] Add keyword-only fields to dataclasses

2021-03-17 Thread Eric V. Smith


New submission from Eric V. Smith :

The idea is that a keyword-only field becomes a keyword-only argument to 
__init__().

For the proposal and a discussion, see 
https://mail.python.org/archives/list/python-id...@python.org/message/FI6KS4O67XDEIDYOFWCXMDLDOSCNSEYG/

The @dataclass decorator will get a new parameter, kw_only, which defaults to 
False. If kw_only=True, all fields in the dataclass will be by efault 
keyword-only. In addition, field() will have a new kw_only parameter. If true, 
the field will be keyword-only. If false, it will not be keyword-only. If 
unspecified, it will use the value of dataclass's kw_only parameter.

In addition, a module-level variable KW_ONLY will be added. If a field has this 
type, then all fields after it will default to kw_only=True. The field is 
otherwise completely ignored.

Examples:

@dataclasses.dataclass
class A:
a: Any = field(kw_only=True) 

Will have __init__(self, *, a)

@dataclasses.dataclass(kw_only=True)
class B:
a: Any
b: Any 

Will have __init__(self, *, a, b)

@dataclasses.dataclass
class C:
a: Any
_: dataclasses.KW_ONLY
b: Any
c: Any

Will have __init__(self, a, *, b, c)

If any non-keyword-only parameters are present, they will be moved before all 
keyword-only parameters, only for the generated __init__. All other generated 
methods (__repr__, __lt__, etc.) will keep fields in the declared order, which 
is the case in versions 3.9 and earlier.

@dataclasses.dataclass
class D:
a: Any
b: Any = field(kw_only=True)
c: Any

Will have __init__(self, a, c, *, b)

PR to follow.

--
assignee: eric.smith
components: Library (Lib)
messages: 388949
nosy: eric.smith
priority: normal
severity: normal
status: open
title: Add keyword-only fields to dataclasses
type: enhancement
versions: Python 3.10

___
Python tracker 

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