Hi Chris, I do not think such a magic linter can be written. It seems an obvious instance of the Halting Problem to me.
If it is possible, then the problem is moot anyway since we can just write it and teach it to treat some arbitrary sentinel NoDefault = object() as the magic value and there will be no need to patch the Python core. Regarding your remark that "you shouldn't return NoDefault anyway": well, *I* will obviously not do so ;-) , but some substantial fraction of programmers will use it as a handy extra sentinel when they can get away with it. And then libraries which deal with processing arbitrary parameters, return values or member values are going to have to deal with the issue if they are going to become "NoDefault-clean" or if they are going to document their NoDefault-uncleanliness. For examples from the standard library, would these work: multiprocessing.Process(target=foo, args=(NoDefault,)) asyncio.AbstractEventLoop.call_later(delay, callback, NoDefault) functools.partial(f, NoDefault) shelve.open("spam")["x"] = NoDefault They should, shouldn't they? I never passed in NoDefault by keyword argument. This generator: def bad_idea(): yield NoDefault can we guarantee it works with all stuff in itertools? And that is just the standard library. Now for all the stuff on Pypy.. Stephan 2017-03-02 13:35 GMT+01:00 Chris Angelico <ros...@gmail.com>: > > On Thu, Mar 2, 2017 at 11:22 PM, Stephan Houben <stephan...@gmail.com> wrote: > > Would this also apply if we provide or capture the keyword arguments using > > ** ? > > > > I.e. > > f(**{"x": NoDict}) > > > > (lambda **kw: kw)(x=NoDict) > > > > In that case I see a problem with this idiom: > > > > newdict = dict(**olddict) > > > > This would now start throwing errors in case any of the values of olddict > > was NoDefault. > > > > You shouldn't be returning NoDefault anywhere, though, so the only > problem is that the error is being reported in the wrong place. If > this were to become syntax, enhanced linters could track down exactly > where NoDefault came from, and report the error, because that's really > where the bug is. > > ChrisA > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/