[issue43761] Documenting dataclass and namedtuple changes for structural pattern matching

2021-04-12 Thread Brandt Bucher


Brandt Bucher  added the comment:

> For named tuples, there isn't an include/exclude option, so no extra mention 
> is warranted.

I think a note in the docs could still be valuable, if only because defining 
__match_args__ for named tuples changes the inherited tuple behavior for 
positional matches quite significantly: "case tuple(x)" and "case MyNT(x)" 
don't mean the same thing.

(Although perhaps this could be inferred from the new constructor signature.)

--

___
Python tracker 

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



[issue43761] Documenting dataclass and namedtuple changes for structural pattern matching

2021-04-10 Thread Eric V. Smith


Eric V. Smith  added the comment:

> Do you need anything from me here?

No, I don't think so. Thanks.

--

___
Python tracker 

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



[issue43761] Documenting dataclass and namedtuple changes for structural pattern matching

2021-04-10 Thread Guido van Rossum


Guido van Rossum  added the comment:

Do you need anything from me here?

--

___
Python tracker 

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



[issue43761] Documenting dataclass and namedtuple changes for structural pattern matching

2021-04-10 Thread Adrian Freund


Adrian Freund  added the comment:

I think for namedtuple a short mention in the opening paragraph, where it also 
mentions the generation of a docstring and __repr__ method should be enough.

--

___
Python tracker 

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



[issue43761] Documenting dataclass and namedtuple changes for structural pattern matching

2021-04-09 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

For named tuples, there isn't an include/exclude option, so no extra mention is 
warranted.

--
nosy: +rhettinger

___
Python tracker 

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



[issue43761] Documenting dataclass and namedtuple changes for structural pattern matching

2021-04-09 Thread Brandt Bucher

Brandt Bucher  added the comment:

If we end up adding a “match_args=False” option to the dataclass decorator 
(issue 43764), then the docs for that option would probably be sufficient for 
this purpose.

I’m imagining something like the docs for the “init” option, just substituting 
“__match_args__” for “__init__()”.

--

___
Python tracker 

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



[issue43761] Documenting dataclass and namedtuple changes for structural pattern matching

2021-04-09 Thread Eric V. Smith


Eric V. Smith  added the comment:

I do think it's worth mentioning that __match_args__ is automatically generated 
by @dataclass (if the class doesn't already define __match_args__). That seems 
like behavior that's very specific to @dataclass. Where else would you find out 
that defining your own __match_args__ prevents @dataclass from adding it?

--

___
Python tracker 

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



[issue43761] Documenting dataclass and namedtuple changes for structural pattern matching

2021-04-09 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
nosy:  -rhettinger

___
Python tracker 

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



[issue43761] Documenting dataclass and namedtuple changes for structural pattern matching

2021-04-09 Thread Adrian Freund


Adrian Freund  added the comment:

I agree that __match_args__ shouldn't have to be added to the documentation of 
any class that supports it, however dataclass and (maybe to a lesser extend) 
NamedTuple aren't themselves classes, but aid in creating own classes. Their 
effects on classes generated by them should be documented.
The documentation also mentions other fields/methods generated by dataclass and 
NamedTyple.

--

___
Python tracker 

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



[issue43761] Documenting dataclass and namedtuple changes for structural pattern matching

2021-04-07 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

> This change is currently not documented in the dataclass 
> and namedtuple documentation,

I don't think we need to do that. In the end, __match_args__ will be added in 
many places.  The right place to document it is in the pattern matching docs.

--
nosy: +rhettinger

___
Python tracker 

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



[issue43761] Documenting dataclass and namedtuple changes for structural pattern matching

2021-04-07 Thread Adrian Freund


Adrian Freund  added the comment:

Ok. I created https://bugs.python.org/issue43764 for that.

--

___
Python tracker 

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



[issue43761] Documenting dataclass and namedtuple changes for structural pattern matching

2021-04-07 Thread Eric V. Smith


Eric V. Smith  added the comment:

Turning off the generation of __match_args__ should be a separate issue.

--

___
Python tracker 

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



[issue43761] Documenting dataclass and namedtuple changes for structural pattern matching

2021-04-07 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +eric.smith

___
Python tracker 

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



[issue43761] Documenting dataclass and namedtuple changes for structural pattern matching

2021-04-07 Thread Adrian Freund


New submission from Adrian Freund :

PEP 634 structural pattern matching adds an auto-generated __match_args__ 
attribute to classes with the dataclass decorator and to namedtuples.

This change is currently not documented in the dataclass and namedtuple 
documentation, nor is it mentioned in PEP 557 Data Classes.


I would suggest adding mentions of this behaviour in those three places.

Additionally I think adding a new parameter to switch off generating 
__match_args__ to dataclass should be considered, as everything else generated 
by dataclass can be switched off using a parameter.

--
assignee: docs@python
components: Documentation
messages: 390413
nosy: brandtbucher, docs@python, freundTech, gvanrossum
priority: normal
severity: normal
status: open
title: Documenting dataclass and namedtuple changes for structural pattern 
matching
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