[Python-Dev] Re: python-iterators mailing list on SourceForge

2021-05-15 Thread Georg Brandl
On 11/05/2021 08:39, Julien Palard via Python-Dev wrote:
> Hi,
> 
> PEP 234 mention
> https://sourceforge.net/p/python/mailman/python-iterators/ but the
> project mailing list archives are marked as "hidden".
> 
> Looks like projects admin and developers can get the "hidden link", but
> I think it would be nice to "unhide" the archives if someone is still
> admin there and if it's possible, to "unbreak" the link from the PEP.

Hi Julien,

I set the mailing list to "closed" which means that the archive is again
available.  However, it looks like only have messages from 2001-2003,
which consist of mostly spam.

Maybe web.archive.org has relevant content archived?

BTW, the linked yahoo list isn't available anymore either.  Probably
best to remove/mark as unavailable the links in the PEP.

cheers,
Georg

___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/OGDX3FIDVQ5KX6NZVJXHD75VBIGGIUX6/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: The repr of a sentinel

2021-05-15 Thread Eric Nieuwland
To add to the suggestions already given in this thread I dug into code I wrote 
some time ago.
Offered as an inspiration.


=== missing.py ===

from typing import Any


def MISSING(klass: Any) -> Any:
"""
create a sentinel to indicate a missing instance of a class
:param klass: the class of which an instance is missing
:return: missing class object
"""
g = globals()
missing_klass_name = 
f"_MISSING_{klass.__module__}_{klass.__name__}_MISSING_"
if missing_klass_name not in g:
g[missing_klass_name] = type(
missing_klass_name,
(klass,),
{
"__repr__": lambda x: f"MISSING({klass.__name__})",
}
)
return g[missing_klass_name]()

===


and as a demo:

=== demo_missing.py ===

import pickle


from missing import MISSING


x = MISSING(str)
y = "bar"
print(f"{x!r} == {y!r}: {x == y}")
print(f"{x!r} is {y!r}: {x is y}")
# MISSING(str) == 'bar': False
# MISSING(str) is 'bar': False

with open("object.pickled", "wb") as f:
pickle.dump(x, f)
with open("object.pickled", "rb") as f:
y = pickle.load(f)
print(f"{x!r} == {y!r}: {x == y}")
print(f"{x!r} is {y!r}: {x is y}")
# MISSING(str) == MISSING(str): True
# MISSING(str) is MISSING(str): False


def foo(a: int = MISSING(int), b: int = MISSING(int)):
print(f"{a=} {isinstance(a, int)}")
print(f"{b=} {isinstance(b, int)}")
print(f"{a!r} == {b!r}: {a == b}")
print(f"{a!r} is {b!r}: {a is b}")


foo()
# a=MISSING(int) True
# b=MISSING(int) True
# MISSING(int) == MISSING(int): True
# MISSING(int) is MISSING(int): False

foo(1)
# a=1 True
# b=MISSING(int) True
# 1 == MISSING(int): False
# 1 is MISSING(int): False


class Test:
...


t = MISSING(Test)
print(f"{t=}")
# t=MISSING(Test)

===
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/42O33BFRJLDFVKX4XSKMZ6VLR7H7GXKP/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: Using FutureWarning for last version before deletion.

2021-05-15 Thread Nick Coghlan
On Tue, 11 May 2021, 7:57 pm Petr Viktorin,  wrote:

>
>
> On 11. 05. 21 11:08, Inada Naoki wrote:
> > On Tue, May 11, 2021 at 5:30 PM Petr Viktorin  wrote:
> >>
> >> Test tools should treat DeprecationWarning as error by default [0][1].
> >> So even if end users don't really see it, I don't consider it "hidden".
> >>
> >
> > *should* is not *do*. For example, nosetests don't show
> DeprecationWarning.
> > And there are many scripts without tests.
> >
> > So it is hidden for some people.
> >
>
> Sadly, there's not much we can do for users of nose. Nose itself is only
> tested with Python 3.5 and below.
>
> I'm aware that there are scripts without tests. But maybe letting them
> suddenly break is the right balance between letting people know and
> annyoing everyone with unactionable warnings.
>

Scripts (with or without tests) have gone back to showing deprecation
warnings by default since 3.7: https://www.python.org/dev/peps/pep-0565/

If DeprecationWarning is not enough, then we should be having a wider
> discussion, and PEP 387 should change. This particular issue should not
> be an exception to the process.
>


The limitations section of PEP 565 covers several known problems even with
the 3.7+ status quo:
https://www.python.org/dev/peps/pep-0565/#limitations-on-pep-scope

Most notably, unit test doesn't catch import time or compile time
deprecation warnings, and it doesn't catch deprecations in subprocesses.

Another case that came up in this thread was support libraries that are
tested with warnings treated as errors, but:

* the test runner still doesn't enable all warnings (e.g. nose projects
that never migrated to nose2)
* the project isn't covered as a dependency by any *other* project's test
suites that are stricter about avoiding deprecation warnings in their code
and the code they use

And, of course, projects that don't treat warnings as errors in their tests
will get a green tick from CI systems no matter how many warnings they emit.

If we wanted to go back to enabling DeprecationWarning by default across
the board, I think we could only reasonably do that if we provided an
easier to use "hide all warnings except the ones I specifically opt in to
seeing" API like the one mentioned at the end of PEP 565:
https://bugs.python.org/issue32229

As currently written, that API proposal would flip the ergonomics problem
though - while ensuring the warnings system was configured early enough to
capture compile time and import time warnings would be up to the
application, being able to easily propagate the config change to
subprocesses would need to be part of the new API design.

Cheers,
Nick.





>
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/NEXGBG6ERDVK6WMDZM6IHPDAQSB4ANIS/
Code of Conduct: http://python.org/psf/codeofconduct/