Change by Eric V. Smith :
--
title: := breaks f-strings -> f-strings do not support top-level :=
___
Python tracker
<https://bugs.python.org/issue36798>
___
_
Change by Eric V. Smith :
--
nosy: +barry
___
Python tracker
<https://bugs.python.org/issue36774>
___
___
Python-bugs-list mailing list
Unsubscribe:
Eric V. Smith added the comment:
Because of the backward compatibility issues, I'm not going to change the
f-string parser for this. We'll just need to document the requirements for
using parens if you want to use :=. This is similar to the existing
documentation about lambdas and
Eric V. Smith added the comment:
I agree with Serhiy about the need to update PEP 572 to mention this.
--
keywords: +easy
stage: -> needs patch
___
Python tracker
<https://bugs.python.org/issu
Eric V. Smith added the comment:
I'm going to close this. Either this problem is going to be addressed
independently of this issue, or it's never going to be fixed. Either way, we
don't need this issue to be open in order to come to a resolution.
--
resolution: -&g
Change by Eric V. Smith :
--
keywords: +patch
pull_requests: +13035
___
Python tracker
<https://bugs.python.org/issue36817>
___
___
Python-bugs-list mailin
Change by Eric V. Smith :
--
type: -> enhancement
___
Python tracker
<https://bugs.python.org/issue36817>
___
___
Python-bugs-list mailing list
Unsubscrib
New submission from Eric V. Smith :
This is an alternative proposal to issue36774.
We (Eric V. Smith and Larry Hastings) propose a minor language
change. This level of change doesn't require a PEP, so in this
post-BDFL world what we need is "a consensus among core developers".
Change by Eric V. Smith :
--
type: -> enhancement
___
Python tracker
<https://bugs.python.org/issue36817>
___
___
Python-bugs-list mailing list
Unsubscrib
Eric V. Smith added the comment:
See issue36817 for an alternative proposal.
--
___
Python tracker
<https://bugs.python.org/issue36774>
___
___
Python-bug
Eric V. Smith added the comment:
I think I meant things like PyFieldNameIter_Type, but it would require some
analysis.
--
versions: +Python 3.8 -Python 3.6
___
Python tracker
<https://bugs.python.org/issue24
Eric V. Smith added the comment:
> Except that I think that !f is not needed. You can use repr by default only
> when no format spec is specified, and add explicit !r if you want to use repr
> with the format spec. If you want to format the value without repr and the
>
Eric V. Smith added the comment:
> In you example the format spec is applied to both the value and the literal
> representation of the expression. Is it an error? I do not think this is an
> expected behavior.
No, you're misreading it. I admit that my example wasn't
New submission from Eric V. Smith :
If either of these lines are added to test_annotations() in
Lib/test/test_future.py, a SystemError will be raised:
eq("(x:=10)")
eq("f'{(x:=10):=10}'")
Traceback (most recent call last):
File "/Users
Eric V. Smith added the comment:
After discussing this with Guido, we're going to go with a tweaked version of
the '=' version of this in issue36817. So, I'm going to close this and continue
the discussion there.
--
resolution: -> rejected
stage: patch re
Eric V. Smith added the comment:
After discussing this with Guido and Larry, we're going to go with the
"implicit format mode", as outlined by Serhiy, and drop the !f feature.
So the rules are:
{x=} -> "x="+repr(x)
{x=:.2f} -> "x="+format(x, &qu
Eric V. Smith added the comment:
The most recent version of the PR 0ec4daead4d5b3c42613bd210a51da60932035f3 has
the behavior without !f and auto-selecting what used to be !f. It's ready for a
final review before I commit it.
--
___
Python tr
Change by Eric V. Smith :
--
pull_requests: +13079
___
Python tracker
<https://bugs.python.org/issue36817>
___
___
Python-bugs-list mailing list
Unsubscribe:
Eric V. Smith added the comment:
New changeset 9a4135e939bc223f592045a38e0f927ba170da32 by Eric V. Smith in
branch 'master':
bpo-36817: Add f-string debugging using '='. (GH-13123)
https://github.com/python/cpython/commit/9a4135e939bc223f5920
Change by Eric V. Smith :
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
New submission from Eric V. Smith :
There are two problems here: what to call this feature, and where to put it.
The current f-string documentation is in Doc/reference/lexical_analysis.rst,
which I'm not sure is the best place to add discussion about how this feature
works. This featu
Eric V. Smith added the comment:
Thanks for adding me, Toshio.
foo = f'{_(f"{first}, bar, and {last}")}'
Wow, that's extremely creative.
I agree that this isn't the best we can do. PEP 501 has some ideas, but it
might be too general purpose and powerful fo
Eric V. Smith added the comment:
I was going to say "use eval()", but maybe we need some sort of
"eval_fstring()" that basically only understood f-strings and produced a
callable that captured all of the variables (like a closure), ma
Eric V. Smith added the comment:
Of course, this wouldn't be any safer than eval'ing arbitrary user provided
code.
--
___
Python tracker
<https://bugs.python.o
Eric V. Smith added the comment:
The goal is to match posix shell semantics. Can you provide a concrete example
where shlex.shlex does something different from a posix-compliant shell? With
all the escaping, it's going to be tough.
Note also that your code raises a DeprecationWarning i
Eric V. Smith added the comment:
Run 3.7 with -Wd:
$ python3 -Wd
Python 3.7.3 (default, Mar 29 2019, 13:03:53)
[GCC 7.4.0] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 'a \; b'
:1: Deprec
Eric V. Smith added the comment:
The existing behavior is what I'd expect.
Using python3:
>>> import ast
>>> s = open('file.py', 'rb').read()
>>> s
b'"""\nHello \\n blah.\n"""\n'
>>> ast.d
Eric V. Smith added the comment:
I agree with Mark: the string is being correctly interpreted by the AST parser,
per Python's tokenizer rules.
You might want to look at lib2to3, which I think is also used by black. It's
also possible that mypy or another static analyzer would be
Eric V. Smith added the comment:
Thanks.
I'm going to be changing the errors as part of #32513, but I'll make sure to
cover this case better.
--
___
Python tracker
<https://bugs.python.o
Eric V. Smith added the comment:
No matter what happens with #32513, I think the right thing to do in this case
is to not error if trying to set __hash__ to None, if it already is None in
__dict__.
--
___
Python tracker
<https://bugs.python.
Eric V. Smith added the comment:
Another case to consider is that if a class defines __eq__, Python will
automatically set hash=False before the decorator gets involved. NOte to self:
be sure to add a test case for this.
--
___
Python tracker
Eric V. Smith added the comment:
See #32546 for the hash=None problem.
--
___
Python tracker
<https://bugs.python.org/issue32513>
___
___
Python-bugs-list mailin
Eric V. Smith added the comment:
This is not an IDLE bug, per se. There's a known problem with f-strings not
producing the correct line numbers. See issue #29051. Unless Terry thinks
there's something IDLE-specific here, I suggest closing this as a duplicate.
--
nosy: +
Eric V. Smith added the comment:
Here is my proposal for making it easier for the user to supply dunder methods
that dataclasses would otherwise automatically add to the class.
For all of these cases, when I talk about init=, repr=, eq=, order=, hash=, or
frozen=, I'm referring t
Eric V. Smith added the comment:
Only hash has the tri-state True/False/None behavior, defaulting to None. It's
this way because None is the "do what's rational, based on eq and frozen"
behavior. None of the other parameters work this way.
There's a long iss
Eric V. Smith added the comment:
I'm sorry the name is confusing to you, but this behavior is correct, and how
dict.update is defined:
https://docs.python.org/3.6/library/stdtypes.html#dict.update
As such, it cannot be changed.
If you want a function that merges values, you'll nee
Eric V. Smith added the comment:
Oops, that should have been:
if init is MISSING:
init = True
--
___
Python tracker
<https://bugs.python.org/issue32
Eric V. Smith added the comment:
The discussion on python-dev was that your ??? box would be "no": if the user
supplied __repr__, they obviously meant for dataclass() to not provide one.
I can't see why the user would say repr=True ("I want dataclass() to add
__repr__&q
Eric V. Smith added the comment:
Rather than re-implementing (and maintaining) functools.total_ordering
semantics, I'd rather advise them to specify order=False and just use
functools.total_ordering. It's an odd use case for dataclass
Eric V. Smith added the comment:
I'm working on a patch before beta 1. The only issue is whether to raise in the
case that order=True and the user specifies one of the 4 ordering dunders. I
think raising is okay, especially since order=False is the default: you'd have
to go out o
Eric V. Smith added the comment:
I'll look at the hash question later today. It's sufficiently complex that I
really want to sit down and work through all of the cases.
--
___
Python tracker
<https://bugs.python.o
Eric V. Smith added the comment:
Here's where I am on what methods are added under which circumstances.
Hopefully these tables don't get mangled.
The more I think about what to do with hash and raising exceptions, the more I
think that the right answer is to not raise any excep
Eric V. Smith added the comment:
I'm working on a better formulation of the __hash__ issue, so don't invest much
time in this until I post my next message. I'm going to re-organize the various
tables to make them easier to read.
--
___
Eric V. Smith added the comment:
I apologize for the length of this, but I want to be as precise as
possible. I've no doubt made some mistakes, so corrections and
discussion are welcomed.
I'm adding the commented text at the end of this message to
dataclasses.py. I'm repeat
Eric V. Smith added the comment:
I'm completely burned out on it, too. I'll get the code checked in today, then
update the PEP later. I don't really want to add all of this reasoning to the
PEP, but I guess I should.
I think the gist of it is correct, in any event. We can
Change by Eric V. Smith :
--
keywords: +patch
pull_requests: +5209
___
Python tracker
<https://bugs.python.org/issue32513>
___
___
Python-bugs-list mailin
Eric V. Smith added the comment:
New changeset ea8fc52e75363276db23c6a8d7a689f79efce4f9 by Eric V. Smith in
branch 'master':
bpo-32513: Make it easier to override dunders in dataclasses. (GH-5366)
https://github.com/python/cpython/commit/ea8fc52e75363276db23c6a8d7a689
Change by Eric V. Smith :
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Eric V. Smith added the comment:
This has been fixed as part of #32513.
--
resolution: -> fixed
stage: -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Change by Eric V. Smith :
--
nosy: +eric.smith
___
Python tracker
<https://bugs.python.org/issue32697>
___
___
Python-bugs-list mailing list
Unsubscribe:
Eric V. Smith added the comment:
This list is for the development of python, not for help with using python.
I suggest you ask your question on the python-list mailing list:
https://mail.python.org/mailman/listinfo/python-list
--
nosy: +eric.smith
resolution: -> not a bug
st
Eric V. Smith added the comment:
I was hoping a volunteer would step up to write the documentation, as it's
definitely not my forte.
Raymond has also volunteered to help.
--
___
Python tracker
<https://bugs.python.org/is
Eric V. Smith added the comment:
Without commenting on how useful or desirable this would be, I'll point out the
string can be computed as:
return f'{int(self):#0{IPV4LENGTH+2}b}'
--
nosy: +eric.smith
___
Python tracker
<https
Eric V. Smith added the comment:
If you don't recognize the format string, you want to fall back to:
return super().__format__(fmt)
Since that will call object.__format__, it will generate an error if fmt is not
the empty string, which is what it does currently for IP addresses.
As f
Eric V. Smith added the comment:
This is the expected behavior, fortunately or not. "math" is not builtin in the
sense that is used in that paragraph.
--
nosy: +eric.smith
___
Python tracker
<https://bugs.python.o
Eric V. Smith added the comment:
Removing macOS since this isn't Mac specific.
--
components: +Interpreter Core -macOS
___
Python tracker
<https://bugs.python.org/is
Change by Eric V. Smith :
--
assignee: -> eric.smith
components: +Library (Lib)
type: crash -> behavior
___
Python tracker
<https://bugs.python.org/i
Eric V. Smith added the comment:
That's a great bug report. Thanks for the tiny code to replicate it.
It turns out the code isn't quite doing what I thought. I'll have to give some
thought to exactly how I'm going to handle this without breaking other cases,
but I shoul
Change by Eric V. Smith :
--
nosy: +ned.deily
priority: normal -> release blocker
___
Python tracker
<https://bugs.python.org/issue32896>
___
___
Python-
Eric V. Smith added the comment:
Agree with Marietta: it's valid, but lets change it to make it more
approachable to non-native speakers.
--
nosy: +eric.smith
___
Python tracker
<https://bugs.python.org/is
Eric V. Smith added the comment:
I'd like 's' to be supported, and just be passed to format(str(self), fmt) (or
some alternate spelling for the same thing).
My use case is to format tables including addresses:
print(f'
Eric V. Smith added the comment:
True enough. You'd think that I (of all people!) would know that. Nevermind.
--
___
Python tracker
<https://bugs.python.org/is
New submission from Eric V. Smith :
See https://mail.python.org/pipermail/python-dev/2018-February/152150.html for
a discussion.
This will remove the @dataclass hash= tri-state parameter, and replace it with
an unsafe_hash= boolean-only parameter.
>From that thread:
"""
I
Eric V. Smith added the comment:
That's a quote from Guido. There weren't any better ideas on the python-dev
thread.
--
nosy: +gvanrossum
___
Python tracker
<https://bugs.python.o
Eric V. Smith added the comment:
Note that this class (from the test suite) will now raise an exception:
@dataclass(unsafe_hash=True)
class C:
i: int
def __eq__(self, other):
return self.i == other.i
That's because it has a __h
Eric V. Smith added the comment:
Here's the simplest way I can describe this, and it's also the table used
inside the code. The column "has-explicit-hash?" is trying to answer the
question "is there a __hash__ function defined in this class?". It is set t
Eric V. Smith added the comment:
if unsafe_hash:
# If there's already a __hash__, raise TypeError, otherwise add
__hash__.
if has_explicit_hash:
hash_action = 'exception'
else:
hash_action = 'add'
else:
#
Change by Eric V. Smith :
--
keywords: +patch
pull_requests: +5663
stage: -> patch review
___
Python tracker
<https://bugs.python.org/issue32929>
___
___
Py
Eric V. Smith added the comment:
I've been focused on getting the code fix in for the next beta release on
2018-02-26, and leaving the possible parameter name change for later. I don't
feel strongly about the parameter name. Right now it's unsafe_hash, per Guido'
New submission from Eric V. Smith :
Reported by Raymond Hettinger:
When working on the docs for dataclasses, something unexpected came up. If a
dataclass is specified to be frozen, that characteristic is inherited by
subclasses which prevents them from assigning additional attributes
Eric V. Smith added the comment:
A related issue is that dataclasses derived from frozen dataclasses are
automatically "promoted" to being frozen.
>>> @dataclass(frozen=True)
... class A:
... i: int
...
>>> @dataclass
... class B(A):
... j: int
...
Eric V. Smith added the comment:
New changeset dbf9cff48a4ad0fd58e1c623ce1f36c3dd3d5f38 by Eric V. Smith in
branch 'master':
bpo-32929: Dataclasses: Change the tri-state hash parameter to the boolean
unsafe_hash. (#5891)
https://github.com/python/cpyt
Eric V. Smith added the comment:
I'm going to close this. Steven: if you gain support for a parameter name
change, please open another issue.
--
priority: release blocker -> normal
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
vers
Eric V. Smith added the comment:
New changeset 4cffe2f66b581fa7538f6de884d54a5c7364d8e0 by Eric V. Smith (Miss
Islington (bot)) in branch '3.7':
bpo-32929: Dataclasses: Change the tri-state hash parameter to the boolean
unsafe_hash. (GH-5891) (GH-5902)
https://github.com/pyth
Eric V. Smith added the comment:
See also PEP 501.
--
nosy: +eric.smith, serhiy.storchaka
___
Python tracker
<https://bugs.python.org/issue32954>
___
___
Pytho
Eric V. Smith added the comment:
Arcadiy: Somehow you're dropping Serhiy and me from the nosy list. I've
re-added us.
--
nosy: +eric.smith, serhiy.storchaka
___
Python tracker
<https://bugs.python.o
Change by Eric V. Smith :
--
priority: release blocker -> deferred blocker
___
Python tracker
<https://bugs.python.org/issue32896>
___
___
Python-bugs-list mai
New submission from Eric V. Smith :
This is a temporary measure until we can better define how frozen inheritance
should work. In the meantime, disallow:
- frozen inherited from non-frozen
- non-frozen inherited from frozen
--
assignee: eric.smith
components: Library (Lib)
messages
Eric V. Smith added the comment:
See issue 32953 for a larger discussion and the ultimate resolution of this.
--
___
Python tracker
<https://bugs.python.org/issue32
Change by Eric V. Smith :
--
keywords: +patch
pull_requests: +5690
stage: -> patch review
___
Python tracker
<https://bugs.python.org/issue32960>
___
___
Py
Eric V. Smith added the comment:
New changeset a93e3dc236279692eaf50b91d358da5983983b14 by Eric V. Smith (Miss
Islington (bot)) in branch '3.7':
bpo-32960: For dataclasses, disallow inheriting frozen from non-frozen classes
and vice-versa, (GH-5919) (GH-5920)
https://github.
Eric V. Smith added the comment:
See https://docs.python.org/2/library/collections.html#collections.namedtuple
namedtuple is called as:
collections.namedtuple(typename, field_names[, verbose=False][, rename=False])
So you are passing in
typename = 'Name'
field_names = 'a'
Eric V. Smith added the comment:
See https://mail.python.org/pipermail/python-dev/2018-February/152320.html for
a discussion.
--
title: Dataclasses: frozen should not be inherited -> Dataclasses: frozen
should not be inherited for non-dataclass derived clas
Eric V. Smith added the comment:
Since this has to wait until 3.8 and I'm swamped with 3.7, this is going to
have to wait for me to look at it.
Is there a reason it needs to be part of dataclasses itself? I'd suggest
separating it out, putting it on PyPI, and getting some trac
Eric V. Smith added the comment:
The format specifier (here, 'x') always goes last.
>>> '{0:_x}'.format(123456789)
'75b_cd15'
See https://docs.python.org/3/library/string.html#formatstrings for the details.
Serhiy is correct that it's often easier
Change by Eric V. Smith :
--
nosy: +eric.smith
___
Python tracker
<https://bugs.python.org/issue33077>
___
___
Python-bugs-list mailing list
Unsubscribe:
Eric V. Smith added the comment:
I once thought of building NamedTuple functionality into dataclasses, either as
a parameter to @dataclass or as a new decorator. But it didn't get very far.
It would have to return a different class, like NamedTuple does, and this
didn't fit in wel
Eric V. Smith added the comment:
Although having said that, we probably can't make that change for 2.7. And
maybe it's even too big a change for 3.8.
--
___
Python tracker
<https://bugs.python.o
Eric V. Smith added the comment:
Wouldn't we be better off to catch this error at parse time, instead of just
improve the error message when .port is called?
I'm not sure why port is a property and not just computed. Maybe the least
intrusive way of doing this would be to jus
Eric V. Smith added the comment:
Yes, you're right, it can't be changed. And .port is documented as raising
ValueError, so it's all working correctly. I think improving the ValueError
message, as the PR does, is as good as we can do.
--
___
Eric V. Smith added the comment:
You did not provide enough information for us to reproduce this problem. To see
the kind of information we need, see for example
https://leantesting.com/write-good-bug-report/
And if you already have determined this is a problem with pip, they have their
own
Change by Eric V. Smith :
--
status: open -> pending
___
Python tracker
<https://bugs.python.org/issue33086>
___
___
Python-bugs-list mailing list
Unsubscrib
Eric V. Smith added the comment:
For backward comparability, option C would have to default to not raising an
exception. Which would limit it's usefulness, but that's the way it goes.
--
___
Python tracker
<https://bugs.python.o
Eric V. Smith added the comment:
Would this change really have a performance impact? Not saying it wouldn't, but
if we're going to add bytecodes we should know the answer in advance.
--
nosy: +eric.smith
___
Python tracker
<https://bu
Change by Eric V. Smith :
--
keywords: +patch
pull_requests: +5905
stage: -> patch review
___
Python tracker
<https://bugs.python.org/issue32953>
___
___
Py
Eric V. Smith added the comment:
New changeset f199bc655eb50c28e94010714629b376bbbd077b by Eric V. Smith in
branch 'master':
bpo-32953: Dataclasses: frozen should not be inherited for non-dataclass
derived classes (#6147)
https://github.com/python/cpyt
Eric V. Smith added the comment:
New changeset 45648312e540cda3b10109b6a808cbf6955c84eb by Eric V. Smith (Miss
Islington (bot)) in branch '3.7':
bpo-32953: Dataclasses: frozen should not be inherited for non-dataclass
derived classes (GH-6147) (GH-6148)
https://github.com/pyth
Change by Eric V. Smith :
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Eric V. Smith added the comment:
There are a couple of problems here. You're using ClassVar incorrectly. It
should be:
>>> @dataclass
... class C:
... __slots__=()
... x: ClassVar[int] = field(default=3)
...
>>> C()
C()
>>> C.x
3
And you cannot have a
Change by Eric V. Smith :
--
versions: +Python 3.8
___
Python tracker
<https://bugs.python.org/issue33094>
___
___
Python-bugs-list mailing list
Unsubscribe:
1601 - 1700 of 2699 matches
Mail list logo