Re: [Python-Dev] Is static typing still optional?

2018-01-29 Thread Greg Ewing
Raymond Hettinger wrote: That list of features is mostly easy-to-use except for hash=None which has three possible values, only one of which is self-evident. Maybe the value of the hash option should be an enum with three explicitly-named values. Or maybe there could be a separate

Re: [Python-Dev] Is static typing still optional?

2018-01-29 Thread Guido van Rossum
I don't think we're going to reach full agreement here, so I'm going to put my weight behind Eric's rules. I think the benefit of the complicated rules is that they almost always do what you want, so you almost never have to think about it. If it doesn't do what you want, setting hash=False or

Re: [Python-Dev] Is static typing still optional?

2018-01-29 Thread Eric V. Smith
On 1/29/2018 4:01 AM, Raymond Hettinger wrote: On Jan 28, 2018, at 11:52 PM, Eric V. Smith wrote: I think it would be a bad design to have to opt-in to hashability if using frozen=True. I respect that you see it that way, but it doesn't make sense to me. You can have

Re: [Python-Dev] Is static typing still optional?

2018-01-29 Thread Ethan Furman
On 01/29/2018 12:57 AM, Eric V. Smith wrote: On 1/29/2018 3:42 AM, Ethan Furman wrote: On 01/28/2018 07:45 AM, Eric V. Smith wrote: I think the hashing logic explained in https://bugs.python.org/issue32513#msg310830 is correct. It uses hash=None as the default, so that frozen=True objects

Re: [Python-Dev] Is static typing still optional?

2018-01-29 Thread Raymond Hettinger
> On Jan 28, 2018, at 11:52 PM, Eric V. Smith wrote: > > I think it would be a bad design to have to opt-in to hashability if using > frozen=True. I respect that you see it that way, but it doesn't make sense to me. You can have either one without the other. It seems

Re: [Python-Dev] Is static typing still optional?

2018-01-29 Thread Eric V. Smith
On 1/29/2018 3:42 AM, Ethan Furman wrote: On 01/28/2018 07:45 AM, Eric V. Smith wrote: On 1/6/2018 5:13 PM, Eric V. Smith wrote: On 12/10/2017 5:00 PM, Raymond Hettinger wrote: 2) Change the default value for "hash" from "None" to "False".  This might take a little effort because there is

Re: [Python-Dev] Is static typing still optional?

2018-01-29 Thread Ethan Furman
On 01/28/2018 07:45 AM, Eric V. Smith wrote: On 1/6/2018 5:13 PM, Eric V. Smith wrote: On 12/10/2017 5:00 PM, Raymond Hettinger wrote: 2) Change the default value for "hash" from "None" to "False". This might take a little effort because there is currently an oddity where setting

Re: [Python-Dev] Is static typing still optional?

2018-01-28 Thread Eric V. Smith
On 1/29/2018 1:55 AM, Yury Selivanov wrote: On Mon, Jan 29, 2018 at 1:36 AM Nick Coghlan > wrote: [...] Currently the answers are: - A: not hashable - B: hashable (by identity) # Wat? - C: hashable (by field hash) - D:

Re: [Python-Dev] Is static typing still optional?

2018-01-28 Thread Yury Selivanov
On Mon, Jan 29, 2018 at 1:36 AM Nick Coghlan wrote: > [...] > Currently the answers are: > > - A: not hashable > - B: hashable (by identity) # Wat? > - C: hashable (by field hash) > - D: hashable (by identity) # Wat? > - E: hashable (by field hash) > - F: hashable (by field

Re: [Python-Dev] Is static typing still optional?

2018-01-28 Thread Nick Coghlan
On 29 January 2018 at 12:08, Guido van Rossum wrote: > I think this is a good candidate for fine-tuning during the beta period. > > Though honestly Python's own rules for when a class is hashable or not are > the root cause for the complexity here -- since we decided to

Re: [Python-Dev] Is static typing still optional?

2018-01-28 Thread Guido van Rossum
I think this is a good candidate for fine-tuning during the beta period. Though honestly Python's own rules for when a class is hashable or not are the root cause for the complexity here -- since we decided to implicitly set __hash__ = None when you define __eq__, it's hardly surprising that

Re: [Python-Dev] Is static typing still optional?

2018-01-28 Thread Raymond Hettinger
>>> 2) Change the default value for "hash" from "None" to "False". This might >>> take a little effort because there is currently an oddity where setting >>> hash=False causes it to be hashable. I'm pretty sure this wasn't intended >>> ;-) >> I haven't looked at this yet. > > I think the

Re: [Python-Dev] Is static typing still optional?

2018-01-28 Thread Eric V. Smith
On 1/6/2018 5:13 PM, Eric V. Smith wrote: On 12/10/2017 5:00 PM, Raymond Hettinger wrote: ... 2) Change the default value for "hash" from "None" to "False".  This might take a little effort because there is currently an oddity where setting hash=False causes it to be hashable.  I'm pretty

Re: [Python-Dev] Is static typing still optional?

2018-01-06 Thread Eric V. Smith
On 12/10/2017 5:00 PM, Raymond Hettinger wrote: On Dec 10, 2017, at 1:37 PM, Eric V. Smith wrote: On 12/10/2017 4:29 PM, Ivan Levkivskyi wrote: On 10 December 2017 at 22:24, Raymond Hettinger > wrote:

Re: [Python-Dev] Is static typing still optional?

2017-12-29 Thread Nick Coghlan
On 30 December 2017 at 11:48, Ned Batchelder wrote: > On 12/29/17 1:59 PM, Guido van Rossum wrote: >> >> Regarding whether this should live on PyPI first, in this case that would >> not be helpful, since attrs is already the category killer on PyPI. So we >> are IMO taking

Re: [Python-Dev] Is static typing still optional?

2017-12-29 Thread Ned Batchelder
On 12/29/17 1:59 PM, Guido van Rossum wrote: Regarding whether this should live on PyPI first, in this case that would not be helpful, since attrs is already the category killer on PyPI. So we are IMO taking the best course possible given that we want something in the stdlib but not exactly

Re: [Python-Dev] Is static typing still optional?

2017-12-29 Thread Guido van Rossum
On Fri, Dec 29, 2017 at 7:10 AM, Stephen J. Turnbull < turnbull.stephen...@u.tsukuba.ac.jp> wrote: > Recently a question has been raised about the decorator overriding > methods defined in the class (especially __repr__). People feel that > if the class defines a method, the decorator should not

Re: [Python-Dev] Is static typing still optional?

2017-12-29 Thread Stephen J. Turnbull
Brett Cannon writes: > I wouldn't characterize it as "big questions". For some people there's a > question as to how to make them work without type hints, but otherwise how > they function is settled. Recently a question has been raised about the decorator overriding methods defined in the

Re: [Python-Dev] Is static typing still optional?

2017-12-29 Thread Stephen J. Turnbull
Brett Cannon writes: > I wouldn't characterize it as "big questions". For some people there's a > question as to how to make them work without type hints, but otherwise how > they function is settled. Recently a question has been raised about the decorator overriding methods defined in the

Re: [Python-Dev] Is static typing still optional?

2017-12-28 Thread Brett Cannon
On Tue, 26 Dec 2017 at 21:00 Ned Batchelder wrote: > On 12/26/17 1:49 PM, Chris Barker wrote: > > On Sat, Dec 23, 2017 at 5:54 PM, Nick Coghlan wrote: > >> >> I still wonder about the "fields *must* be annotated" constraint though. >> I can understand

Re: [Python-Dev] Is static typing still optional?

2017-12-26 Thread Ned Batchelder
On 12/26/17 1:49 PM, Chris Barker wrote: On Sat, Dec 23, 2017 at 5:54 PM, Nick Coghlan > wrote: I still wonder about the "fields *must* be annotated" constraint though. I can understand a constraint that the style be *consistent*

Re: [Python-Dev] Is static typing still optional?

2017-12-26 Thread Eric V. Smith
On 12/21/2017 6:36 AM, Ivan Levkivskyi wrote: On 21 December 2017 at 11:22, Terry Reedy > wrote: On 12/21/2017 4:22 AM, Eric V. Smith wrote: On 12/21/2017 1:46 AM, Chris Barker wrote: I suggest that it be clear in the docs,

Re: [Python-Dev] Is static typing still optional?

2017-12-26 Thread Ivan Levkivskyi
On 22 December 2017 at 20:55, Brett Cannon wrote: > > > On Fri, Dec 22, 2017, 11:38 Chris Barker, wrote: > >> On Fri, Dec 22, 2017 at 8:49 AM, Brett Cannon wrote: >> >>> I think it's worth reminding people that if they don't like the

Re: [Python-Dev] Is static typing still optional?

2017-12-26 Thread Chris Barker
On Sat, Dec 23, 2017 at 5:54 PM, Nick Coghlan wrote: > > I still wonder about the "fields *must* be annotated" constraint though. I > can understand a constraint that the style be *consistent* (i.e. all fields > as annotations, or all fields as field instances), since that's

Re: [Python-Dev] Is static typing still optional?

2017-12-23 Thread Nick Coghlan
On 23 Dec. 2017 9:37 am, "David Mertz" wrote: There name Data seems very intuitive to me without suggesting type declaration as Any does (but it can still be treated as a synonym by actual type checkers) Type checkers would also be free to interpret it as "infer the type from

Re: [Python-Dev] Is static typing still optional?

2017-12-22 Thread Chris Barker
On Fri, Dec 22, 2017 at 1:18 PM, MRAB wrote: > >> The function is "any", the type is "Any", and "any" != "Any", although I > wonder how many people will be caught out by that... enough that it's a bad idea oh well. -CHB >

Re: [Python-Dev] Is static typing still optional?

2017-12-22 Thread MRAB
On 2017-12-22 21:02, Mike Miller wrote: On 2017-12-22 12:15, Chris Barker wrote: Would it be crazy to bring typing.Any into the builtin namespace? @dataclass:     a: Any     b: Any = 34     c: int = 0 That reads pretty well to me > And having Any available in the built in namespace

Re: [Python-Dev] Is static typing still optional?

2017-12-22 Thread Mike Miller
On 2017-12-22 12:15, Chris Barker wrote: Would it be crazy to bring typing.Any into the builtin namespace? @dataclass:     a: Any     b: Any = 34     c: int = 0 That reads pretty well to me > And having Any available in the built in namespace may help in other cases where There is

Re: [Python-Dev] Is static typing still optional?

2017-12-22 Thread David Mertz
There name Data seems very intuitive to me without suggesting type declaration as Any does (but it can still be treated as a synonym by actual type checkers) On Dec 22, 2017 12:12 PM, "Paul Moore" wrote: > On 22 December 2017 at 19:50, Gregory P. Smith

Re: [Python-Dev] Is static typing still optional?

2017-12-22 Thread Chris Barker
On Fri, Dec 22, 2017 at 10:10 AM, Stephan Hoyer wrote: > On Thu, Dec 21, 2017 at 6:39 AM Ivan Levkivskyi > wrote: > >> > * ... (ellipsis): this class may or may not be used with static type >> checkers, use the inferred type in the latter case >> > > *

Re: [Python-Dev] Is static typing still optional?

2017-12-22 Thread Paul Moore
On 22 December 2017 at 19:50, Gregory P. Smith wrote: > My preference for this is "just use Any" for anyone not concerned about the > type. But if we wanted to make it more opaque so that people need not > realizing that they are actually type annotations, I suggest adding an

Re: [Python-Dev] Is static typing still optional?

2017-12-22 Thread Brett Cannon
On Fri, Dec 22, 2017, 11:38 Chris Barker, wrote: > On Fri, Dec 22, 2017 at 8:49 AM, Brett Cannon wrote: > >> I think it's worth reminding people that if they don't like the fact >>> dataclasses (ab)use type hints for their succinct syntax that you can

Re: [Python-Dev] Is static typing still optional?

2017-12-22 Thread Gregory P. Smith
On Fri, Dec 22, 2017 at 11:40 AM Chris Barker wrote: > On Fri, Dec 22, 2017 at 8:49 AM, Brett Cannon > But I think the key point I want to make is Guido chose dataclasses to >> support using the type hints syntax specifically over how attrs does >>

Re: [Python-Dev] Is static typing still optional?

2017-12-22 Thread Chris Barker
On Fri, Dec 22, 2017 at 8:49 AM, Brett Cannon wrote: > I think it's worth reminding people that if they don't like the fact >> dataclasses (ab)use type hints for their succinct syntax that you can >> always use attrs instead to avoid type hints. >> > sure -- but this doesn't

Re: [Python-Dev] Is static typing still optional?

2017-12-22 Thread Stephan Hoyer
On Thu, Dec 21, 2017 at 6:39 AM Ivan Levkivskyi wrote: > For me, the three options for "don't care" have a bit different meaning: > > * typing.Any: this class is supposed to be used with static type checkers, > but this field is too dynamic > * ... (ellipsis): this class

Re: [Python-Dev] Is static typing still optional?

2017-12-22 Thread Brett Cannon
On Thu, Dec 21, 2017, 03:37 Ivan Levkivskyi, wrote: > On 21 December 2017 at 11:22, Terry Reedy wrote: > >> On 12/21/2017 4:22 AM, Eric V. Smith wrote: >> >>> On 12/21/2017 1:46 AM, Chris Barker wrote: >>> >> >> I suggest that it be clear in the docs, and

Re: [Python-Dev] Is static typing still optional?

2017-12-21 Thread Chris Barker
On Thu, Dec 21, 2017 at 3:36 PM, Gregory P. Smith wrote: > But we already have ... which does - so I'd suggest that for people who > are averse to importing anything from typing and using the also quite > readable Any. (ie: document this as the expected practice with both

Re: [Python-Dev] Is static typing still optional?

2017-12-21 Thread Gregory P. Smith
On Thu, Dec 21, 2017 at 3:10 PM MRAB wrote: > On 2017-12-21 22:45, Chris Barker wrote: > > On Thu, Dec 21, 2017 at 11:55 AM, Terry Reedy > > wrote: > > > > I think the understanding problem with this feature arises from

Re: [Python-Dev] Is static typing still optional?

2017-12-21 Thread MRAB
On 2017-12-21 22:45, Chris Barker wrote: On Thu, Dec 21, 2017 at 11:55 AM, Terry Reedy > wrote: I think the understanding problem with this feature arises from two factors: using annotations to define possibly un-initialized slots is

Re: [Python-Dev] Is static typing still optional?

2017-12-21 Thread Chris Barker
On Thu, Dec 21, 2017 at 11:55 AM, Terry Reedy wrote: I think the understanding problem with this feature arises from two > factors: using annotations to define possibly un-initialized slots is > non-obvious; a new use of annotations for something other than static > typing is a

Re: [Python-Dev] Is static typing still optional?

2017-12-21 Thread Steve Holden
On Thu, Dec 21, 2017 at 7:55 PM, Terry Reedy wrote: > On 12/21/2017 9:23 AM, Eric V. Smith wrote: > >> >> >> On 12/21/17 6:25 AM, Sven R. Kunze wrote: >> >>> On 21.12.2017 11:22, Terry Reedy wrote: >>> @dataclass >> class C: >> a: int # integer field with

Re: [Python-Dev] Is static typing still optional?

2017-12-21 Thread Terry Reedy
On 12/21/2017 9:23 AM, Eric V. Smith wrote: On 12/21/17 6:25 AM, Sven R. Kunze wrote: On 21.12.2017 11:22, Terry Reedy wrote: @dataclass class C: a: int # integer field with no default b: float = 0.0 # float field with a default And the types will be recognized by type checkers

Re: [Python-Dev] Is static typing still optional?

2017-12-21 Thread Eric V. Smith
On 12/21/17 6:25 AM, Sven R. Kunze wrote: On 21.12.2017 11:22, Terry Reedy wrote: @dataclass class C: a: int # integer field with no default b: float = 0.0 # float field with a default And the types will be recognized by type checkers such as mypy. And I think the non-typed

Re: [Python-Dev] Is static typing still optional?

2017-12-21 Thread Ivan Levkivskyi
On 21 December 2017 at 11:22, Terry Reedy wrote: > On 12/21/2017 4:22 AM, Eric V. Smith wrote: > >> On 12/21/2017 1:46 AM, Chris Barker wrote: >> > > I suggest that it be clear in the docs, and ideally in the PEP, that the >>> dataclass decorator is using the *annotation"

Re: [Python-Dev] Is static typing still optional?

2017-12-21 Thread Sven R. Kunze
On 21.12.2017 11:22, Terry Reedy wrote: @dataclass class C: a: int # integer field with no default b: float = 0.0 # float field with a default And the types will be recognized by type checkers such as mypy. And I think the non-typed examples should go first in the docs. I still

Re: [Python-Dev] Is static typing still optional?

2017-12-21 Thread Terry Reedy
On 12/21/2017 4:22 AM, Eric V. Smith wrote: On 12/21/2017 1:46 AM, Chris Barker wrote: I suggest that it be clear in the docs, and ideally in the PEP, that the dataclass decorator is using the *annotation" syntax, and that the the only relevant part it uses is that an annotation exists, but

Re: [Python-Dev] Is static typing still optional?

2017-12-21 Thread Eric V. Smith
On 12/21/2017 1:46 AM, Chris Barker wrote: On Wed, Dec 20, 2017 at 5:29 PM, Eric V. Smith > wrote: There is definitely a passive bias towards using types with dataclasses in that the Eric (the author) doesn't appear to want an example

Re: [Python-Dev] Is static typing still optional?

2017-12-20 Thread Chris Barker
On Wed, Dec 20, 2017 at 5:29 PM, Eric V. Smith wrote: > There is definitely a passive bias towards using types with dataclasses in > that the Eric (the author) doesn't appear to want an example without them > in the pep/docs. > >> >> I'm not sure what such an example would

Re: [Python-Dev] Is static typing still optional?

2017-12-20 Thread Eric V. Smith
On 12/20/2017 8:13 PM, Eric V. Smith wrote: There is definitely a passive bias towards using types with dataclasses in that the Eric (the author) doesn't appear to want an example without them in the pep/docs. I'm not sure what such an example would look like. Do you mean without

Re: [Python-Dev] Is static typing still optional?

2017-12-20 Thread Eric V. Smith
On 12/20/2017 6:57 PM, Mike Miller wrote: On 2017-12-19 02:53, Paul Moore wrote: Also, the fact that no-one raised this issue during the whole time the PEP was being discussed (at least as far as I recollect) and that Guido (who of all of us should be most aware of what is and isn't acceptable

Re: [Python-Dev] Is static typing still optional?

2017-12-20 Thread Mike Miller
On 2017-12-19 02:53, Paul Moore wrote: Also, the fact that no-one raised this issue during the whole time the PEP was being discussed (at least as far as I recollect) and that Guido (who of all of us should be most aware of what is and isn't acceptable use of annotations in the stdlib) approved

Re: [Python-Dev] Is static typing still optional?

2017-12-19 Thread Rob Cliffe
On 19/12/2017 20:11, Chris Barker wrote: There are a number of us that are uncomfortable with static typing in general, +1 and the python-dev community has been criticised for doing too much, moving too fast, and complicating the language unnecessarily.

Re: [Python-Dev] Is static typing still optional?

2017-12-19 Thread Chris Barker
On Mon, Dec 18, 2017 at 11:49 PM, Eric V. Smith wrote: > I also don't think it's surprising that you can put misleading information > (including non-types) in type annotations. All of the documentation and > discussions are quite clear that type information is ignored at

Re: [Python-Dev] Is static typing still optional?

2017-12-19 Thread Steve Holden
On Tue, Dec 19, 2017 at 10:53 AM, Paul Moore wrote: > On 19 December 2017 at 07:49, Eric V. Smith wrote: > > Data Classes is also not the first use of type annotations in the stdlib: > > https://docs.python.org/3/library/typing.html#typing.NamedTuple > >

Re: [Python-Dev] Is static typing still optional?

2017-12-19 Thread Paul Moore
On 19 December 2017 at 07:49, Eric V. Smith wrote: > Data Classes is also not the first use of type annotations in the stdlib: > https://docs.python.org/3/library/typing.html#typing.NamedTuple > Also, the fact that no-one raised this issue during the whole time the PEP was

Re: [Python-Dev] Is static typing still optional?

2017-12-18 Thread Eric V. Smith
On 12/18/2017 9:41 PM, Chris Barker wrote: I'm really surprised no one seems to get my point here. TL;DR: My point is that having type annotation syntax required for something in the stdlib is a significant step toward "normalizing" type hinting in Python. Whether that's a good idea or not is

Re: [Python-Dev] Is static typing still optional?

2017-12-18 Thread Barry Warsaw
On Dec 18, 2017, at 21:41, Chris Barker wrote: > > TL;DR: > My point is that having type annotation syntax required for something in the > stdlib is a significant step toward "normalizing" type hinting in Python. > Whether that's a good idea or not is a judgement call,

Re: [Python-Dev] Is static typing still optional?

2017-12-18 Thread Chris Barker
I'm really surprised no one seems to get my point here. TL;DR: My point is that having type annotation syntax required for something in the stdlib is a significant step toward "normalizing" type hinting in Python. Whether that's a good idea or not is a judgement call, but it IS a big step.

Re: [Python-Dev] Is static typing still optional?

2017-12-18 Thread Eric V. Smith
On 12/18/2017 2:55 PM, Ivan Levkivskyi wrote: On 18 December 2017 at 20:38, Nick Coghlan > wrote: On 19 Dec. 2017 7:00 am, "Chris Barker" > wrote: Are there other options??

Re: [Python-Dev] Is static typing still optional?

2017-12-18 Thread Ivan Levkivskyi
On 18 December 2017 at 20:38, Nick Coghlan wrote: > > On 19 Dec. 2017 7:00 am, "Chris Barker" wrote: > > > Are there other options?? > > plain old: > > @dataclass > class C: > a = 1 > b = 1.0 > > would work, though then there would be no way to

Re: [Python-Dev] Is static typing still optional?

2017-12-18 Thread Nick Coghlan
On 19 Dec. 2017 7:00 am, "Chris Barker" wrote: Are there other options?? plain old: @dataclass class C: a = 1 b = 1.0 would work, though then there would be no way to express fields without defaults: The PEP already supports using "a = field(); b = field()"

Re: [Python-Dev] Is static typing still optional?

2017-12-18 Thread Ivan Levkivskyi
@David What you propose as `Infer` annotation was proposed some time ago (not only for dataclasses, there are other use cases). The discussion is here https://github.com/python/typing/issues/276 @Chris People are still allowed not to use dataclasses if they really don't like type hints :-)

Re: [Python-Dev] Is static typing still optional?

2017-12-18 Thread Chris Barker
Good Bad or Neutral, this discussion makes my point: Using typing annotation as a necessary part of a standard library module is injecting typing into "ordinary" python in a new way. It is no longer going to appear to be completely optional, and only of concern to those that choose to use it

Re: [Python-Dev] Is static typing still optional?

2017-12-17 Thread David Mertz
On Sun, Dec 17, 2017 at 8:22 AM, Guido van Rossum wrote: > On Sun, Dec 17, 2017 at 2:11 AM, Julien Salort wrote: > >> Naive question from a lurker: does it mean that it works also if one >> annotates with something that is not a type, e.g. a comment, >> >>

Re: [Python-Dev] Is static typing still optional?

2017-12-17 Thread Guido van Rossum
On Sun, Dec 17, 2017 at 2:11 AM, Julien Salort wrote: > Le 15/12/2017 à 22:14, Paul Moore a écrit : > > Annotations and the annotation syntax are fundamental to the design. >> But that's core Python syntax. But I wouldn't describe types as being >> that significant to the

Re: [Python-Dev] Is static typing still optional?

2017-12-17 Thread Julien Salort
Le 15/12/2017 à 22:14, Paul Moore a écrit : Annotations and the annotation syntax are fundamental to the design. But that's core Python syntax. But I wouldn't describe types as being that significant to the design, it's more "if you supply them we'll make use of them". Naive question from a

Re: [Python-Dev] Is static typing still optional?

2017-12-15 Thread Paul Moore
On 15 December 2017 at 20:07, Chris Barker wrote: > And if I understand the rest of the PEP, while typing itself is optional, > the use of type Annotation is not -- it is exactly what's being used to > generate the fields the user wants. > > And the examples are all using

Re: [Python-Dev] Is static typing still optional?

2017-12-15 Thread Chris Barker
One other note (see my last message). The PEP should include a summary of the discussion of the decision to use the type annotation syntax vs other options. I just looked through all the gitHub issues and found nothing, and started to look at the python-ideas list archive and got overwhelmed.

Re: [Python-Dev] Is static typing still optional?

2017-12-15 Thread Chris Barker
Sorry about the email mangling -- I do a lot of my listserve work on the bus on an iPhone, with the built -in mail client -- and it REALLY sucks for doing interspersed email replying -- highly encouraging the dreaded top posting... But anyway, I think both Steve and I were expressing concerns

Re: [Python-Dev] Is static typing still optional?

2017-12-15 Thread Eric V. Smith
On 12/15/2017 5:56 AM, Steve Holden wrote: On Mon, Dec 11, 2017 at 5:10 PM, Chris Barker - NOAA Federal > wrote: ... However, typing is not currently imported by dataclasses.py. > And there you have an actual reason besides my

Re: [Python-Dev] Is static typing still optional?

2017-12-15 Thread Steve Holden
On Mon, Dec 11, 2017 at 5:10 PM, Chris Barker - NOAA Federal < chris.bar...@noaa.gov> wrote: > . > > I see a couple of options: > 1a: Use a default type annotation, if one is not is supplied. typing.Any > would presumably make the most sense. > 1b: Use None if not type is supplied. > 2: Rework

Re: [Python-Dev] Is static typing still optional?

2017-12-12 Thread Eric V. Smith
On 12/11/2017 9:25 PM, Nick Coghlan wrote: On 11 Dec. 2017 12:26 pm, "Eric V. Smith" > wrote: I see a couple of options: 1a: Use a default type annotation, if one is not is supplied. typing.Any would presumably make the most sense.

Re: [Python-Dev] Is static typing still optional?

2017-12-11 Thread Nick Coghlan
On 11 Dec. 2017 12:26 pm, "Eric V. Smith" wrote: I see a couple of options: 1a: Use a default type annotation, if one is not is supplied. typing.Any would presumably make the most sense. 1b: Use None if not type is supplied. 2: Rework the code to not require annotations at

Re: [Python-Dev] Is static typing still optional?

2017-12-11 Thread Eric V. Smith
On 12/10/2017 5:00 PM, Raymond Hettinger wrote: On Dec 10, 2017, at 1:37 PM, Eric V. Smith wrote: On 12/10/2017 4:29 PM, Ivan Levkivskyi wrote: On 10 December 2017 at 22:24, Raymond Hettinger > wrote:

Re: [Python-Dev] Is static typing still optional?

2017-12-11 Thread Chris Barker - NOAA Federal
. I see a couple of options: 1a: Use a default type annotation, if one is not is supplied. typing.Any would presumably make the most sense. 1b: Use None if not type is supplied. 2: Rework the code to not require annotations at all. I think I'd prefer 1a, since it's easy. 2) would be great :-)

Re: [Python-Dev] Is static typing still optional?

2017-12-10 Thread Eric V. Smith
On 12/10/2017 5:00 PM, Raymond Hettinger wrote: On Dec 10, 2017, at 1:37 PM, Eric V. Smith wrote: On 12/10/2017 4:29 PM, Ivan Levkivskyi wrote: On 10 December 2017 at 22:24, Raymond Hettinger > wrote:

Re: [Python-Dev] Is static typing still optional?

2017-12-10 Thread Raymond Hettinger
> On Dec 10, 2017, at 1:37 PM, Eric V. Smith wrote: > > On 12/10/2017 4:29 PM, Ivan Levkivskyi wrote: >> On 10 December 2017 at 22:24, Raymond Hettinger >> > wrote: >>Without typing (only the first

Re: [Python-Dev] Is static typing still optional?

2017-12-10 Thread Eric V. Smith
On 12/10/2017 4:29 PM, Ivan Levkivskyi wrote: On 10 December 2017 at 22:24, Raymond Hettinger > wrote: Without typing (only the first currently works):     Point = namedtuple('Point', ['x', 'y', 'z'])          #

Re: [Python-Dev] Is static typing still optional?

2017-12-10 Thread Ivan Levkivskyi
On 10 December 2017 at 22:24, Raymond Hettinger wrote: > Without typing (only the first currently works): > > Point = namedtuple('Point', ['x', 'y', 'z']) # underlying > store is a tuple > Point = make_dataclass('Point', ['x', 'y', 'z']) #

[Python-Dev] Is static typing still optional?

2017-12-10 Thread Raymond Hettinger
The make_dataclass() factory function in the dataclasses module currently requires type declarations. It would be nice if the type declarations were optional. With typing (currently works): Point = NamedTuple('Point', [('x', float), ('y', float), ('z', float)]) Point =