[issue10868] ABCMeta.register() should work as a decorator

2011-02-26 Thread Edoardo Spadolini

Edoardo Spadolini keri...@gmail.com added the comment:

Not really, but putting something in your inheritance lattice only to mark a 
class as providing an interface just doesn't seem right to me.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10868
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10868] ABCMeta.register() should work as a decorator

2011-02-26 Thread Daniel Urban

Daniel Urban urban.dani...@gmail.com added the comment:

 In what use-cases would you want to call MyABC.register() when defining
 a class instead of inheriting from MyABC?

For example if you don't want to inherit a __dict__ for a tree-like data 
structure (see also issue11333).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10868
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10868] ABCMeta.register() should work as a decorator

2011-02-26 Thread Daniel Stutzbach

Daniel Stutzbach stutzb...@google.com added the comment:

Sounds good to me.  Thanks for the clarifications and satisfying my curiosity! 
:-)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10868
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10868] ABCMeta.register() should work as a decorator

2011-02-24 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Committed to py3k as r88545.  You’ll notice that I fixed the nesting of the 
versionchanged directive and that I changed my mind about “returns”.  Thanks 
again!

--
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10868
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10868] ABCMeta.register() should work as a decorator

2011-02-24 Thread Daniel Stutzbach

Daniel Stutzbach stutzb...@google.com added the comment:

In what use-cases would you want to call MyABC.register() when defining a class 
instead of inheriting from MyABC?

I always thought of the register() as hack to make it possible to support types 
written in C, which can't inherit from the ABC.

--
nosy: +stutzbach

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10868
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10868] ABCMeta.register() should work as a decorator

2011-02-24 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Someone may want to register with an ABC but not inherit methods or add a class 
to the mro.  It’s always been allowed by the register method; the new decorator 
feature is just a very minor nicety on top of that.

Edoardo, was your request motivated by a real use case where you didn’t want to 
inherit from the ABC?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10868
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10868] ABCMeta.register() should work as a decorator

2011-01-11 Thread Edoardo Spadolini

Edoardo Spadolini keri...@gmail.com added the comment:

Yeah, I should've waited for the test to finish, but come on, it was just a 
small change :(

Now I know why you should always test everything at least, sorry about that :)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10868
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10868] ABCMeta.register() should work as a decorator

2011-01-10 Thread Daniel Urban

Daniel Urban urban.dani...@gmail.com added the comment:

There is another return statement earlier in the ABCMeta.register method. The 
patch probably should also modify that.

--
nosy: +durban

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10868
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10868] ABCMeta.register() should work as a decorator

2011-01-10 Thread Edoardo Spadolini

Edoardo Spadolini keri...@gmail.com added the comment:

Whoops, corrected that - should I add some more tests for that too?

--
nosy:  -benjamin.peterson, durban, eric.araujo, gvanrossum, pitrou, rhettinger
Added file: http://bugs.python.org/file20335/abcmeta_register_v4.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10868
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10868] ABCMeta.register() should work as a decorator

2011-01-10 Thread Edoardo Spadolini

Changes by Edoardo Spadolini keri...@gmail.com:


--
nosy: +benjamin.peterson, durban, eric.araujo, gvanrossum, pitrou, rhettinger

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10868
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10868] ABCMeta.register() should work as a decorator

2011-01-10 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

You should, otherwise how would you prove it’s fixed? :)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10868
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10868] ABCMeta.register() should work as a decorator

2011-01-10 Thread Edoardo Spadolini

Edoardo Spadolini keri...@gmail.com added the comment:

Fair enough :)

--
Added file: http://bugs.python.org/file20336/abcmeta_register_v4_plus_tests.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10868
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10868] ABCMeta.register() should work as a decorator

2011-01-10 Thread Edoardo Spadolini

Changes by Edoardo Spadolini keri...@gmail.com:


Removed file: 
http://bugs.python.org/file20336/abcmeta_register_v4_plus_tests.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10868
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10868] ABCMeta.register() should work as a decorator

2011-01-10 Thread Edoardo Spadolini

Changes by Edoardo Spadolini keri...@gmail.com:


Added file: http://bugs.python.org/file20337/abcmeta_register_v4_plus_tests.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10868
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10868] ABCMeta.register() should work as a decorator

2011-01-10 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

-return  # Already a subclass
+return subclass # Already a subclass
PEP 8 advises to put two spaces before inline comments, for readability.
 (There is no need to upload a new patch, I’ll change that before commit.)

+self.assertIsInstahce(c, (A,))
This is fixed in the newest version of your patch.  Running tests before
uploading diffs catches such errors :)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10868
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10868] ABCMeta.register() should work as a decorator

2011-01-08 Thread Edoardo Spadolini

New submission from Edoardo Spadolini keri...@gmail.com:

If we make ABCMeta.register() return the registered class, like 
atexit.register() does for the registered function, we can then use it as a 
decorator:

Now:

class Foo:
...
ABarC.register(Foo)

With this change:

@ABarC.register
class Foo:
...

The only problem this would cause is in code that relies on ABCMeta.register() 
to return None; I can't think of a reason anyone would rely on this, but...

--
components: Library (Lib)
files: abcmeta_register_deco.diff
keywords: patch
messages: 125804
nosy: kerio
priority: normal
severity: normal
status: open
title: ABCMeta.register() should work as a decorator
type: feature request
versions: Python 3.3
Added file: http://bugs.python.org/file20314/abcmeta_register_deco.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10868
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10868] ABCMeta.register() should work as a decorator

2011-01-08 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

Looks like a good idea to me.

--
nosy: +benjamin.peterson, gvanrossum, pitrou
stage:  - patch review

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10868
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10868] ABCMeta.register() should work as a decorator

2011-01-08 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Thanks for the report and patch.  Some comments:


+Register a virtual subclass of an ABC. Returns the said subclass.
Should be “Return”, for consistency.

+return subclass # For usage as a decorator
I’d move that to the docstring.

Can you edit the docs (remember to use the versionchanged directive) too?

--
assignee:  - eric.araujo
nosy: +eric.araujo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10868
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10868] ABCMeta.register() should work as a decorator

2011-01-08 Thread Edoardo Spadolini

Edoardo Spadolini keri...@gmail.com added the comment:

Ok, edited the docs too; hope I did everything right...

--
Added file: 
http://bugs.python.org/file20315/abcmeta_register_deco_with_docs.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10868
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10868] ABCMeta.register() should work as a decorator

2011-01-08 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Edited your patch to fix some nits.  If there is no opposition, I’ll commit 
this to py3k when 3.2 is out.

--
Added file: http://bugs.python.org/file20316/abcmeta_register_v3.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10868
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10868] ABCMeta.register() should work as a decorator

2011-01-08 Thread Raymond Hettinger

Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

+1

--
nosy: +rhettinger

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10868
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com