Franklin? Lee added the comment: I probably won't submit a patch, but I can definitely write a bunch of private notes toward a patch and forget about them. >_>
Idea 1: Crawl up the call tree and see whether you hit a module definition or a class definition first. Idea 2: Inspect __qualname__ to determine whether it's a method/inner function. That might have the same problems with @wraps, though, and you wouldn't be allowed to use a classmethod as a module's function. Idea 2 seems to be the right thing. If ".__qualname__ != .__name__", it's an error. If you really want to use `public` in the above cases, you should use the assignment form of `public` (whatever it turns out to be), or explicitly append to __all__. Rule: The programmer should not explicitly use `public(a_func)`, and should use assignment-form `public` if `@public` is not possible (== the decorator form is not being used at the point of definition). I think this way won't have errors passing silently and failing mysteriously. First draft of error message (not considering assignment-form): "'public' should only be used as a decorator for a function/class in module scope." ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26632> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com