[issue11339] annotation for class being defined

2022-03-25 Thread Irit Katriel


Change by Irit Katriel :


--
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11339] annotation for class being defined

2022-03-25 Thread Jelle Zijlstra


Jelle Zijlstra  added the comment:

Agree. typing.Self from PEP 673 fixes this specific case, and PEP 563 or 649 
will provide a general solution. No need to keep this issue open.

--
nosy: +JelleZijlstra
status: pending -> open

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11339] annotation for class being defined

2022-03-24 Thread Irit Katriel

Irit Katriel  added the comment:

This looks like PEP 673 – Self Type.

--
nosy: +iritkatriel
resolution:  -> out of date
status: open -> pending

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11339] annotation for class being defined

2021-03-15 Thread Kamil Turek


Change by Kamil Turek :


--
nosy: +kamilturek

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11339] annotation for class being defined

2021-03-15 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Is this issue resolved with PEP 563 and the behavior becoming default in Python 
3.10? https://www.python.org/dev/peps/pep-0563/#forward-references

--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11339] annotation for class being defined

2021-03-15 Thread Socob


Change by Socob <206a8...@opayq.com>:


--
nosy: +Socob

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11339] annotation for class being defined

2017-02-13 Thread Ivan Levkivskyi

Changes by Ivan Levkivskyi :


--
nosy: +levkivskyi

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11339] annotation for class being defined

2017-01-12 Thread Ryan Hiebert

Changes by Ryan Hiebert :


--
nosy: +ryanhiebert

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11339] annotation for class being defined

2011-07-09 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
nosy: +eric.araujo

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



[issue11339] annotation for class being defined

2011-07-09 Thread Eric Snow

Changes by Eric Snow ericsnowcurren...@gmail.com:


--
nosy: +ericsnow

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



[issue11339] annotation for class being defined

2011-03-04 Thread Terry J. Reedy

Terry J. Reedy tjre...@udel.edu added the comment:

The basic problem is that the class object is defined after the class 
definitions have been made,

I have sometimes thought the the class statement could start with binding the 
name to a blank object or new, blank class object. But then people might try to 
grab attributes (and fail!) outside of method defs.

--
nosy: +terry.reedy

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



[issue11339] annotation for class being defined

2011-02-27 Thread Raymond Hettinger

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

This would be an important fix-up if we could find some way to implement it.

The basic problem is that the class object is defined after the class 
definitions have been made, so the target of the Graph reference isn't known 
when the method definitions are being compiled.

One approach to solving this problem is to use a deferred/resolved pattern 
(creating a valid reference to Graph that is visible during method compilation, 
but gets filled-in with the other methods afterwards).

I haven't thought this through completely but think it could be done if we let 
the compiler write to the class dictionary (this is normally off-limits and 
protected by a dict_proxy).  If we let the system punch a hole in the proxy, it 
is possible to resolve deferred class definitions.

Here's a concept sketch:

class Prepared(type):
'Preload the class with a reference to itself'
@classmethod
def __prepare__(mcl, name, bases):
return {name: type(name, bases, {})}
def __new__(mcl, name, bases, mapping):
global deferred_class
tmpcls = super().__new__(mcl, name, bases, mapping)
deferred_class = mapping[name]
deferred_class.__dict__.update(tmpcls.__dict__)  # XXX need writeable 
dict_proxy
return deferred_class

class Graph(metaclass=Prepared):
def reverse(self) - Graph:
...

--
nosy: +arigo, rhettinger, stutzbach
resolution: rejected - 
status: closed - open

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



[issue11339] annotation for class being defined

2011-02-27 Thread Raymond Hettinger

Changes by Raymond Hettinger rhettin...@users.sourceforge.net:


--
Removed message: http://bugs.python.org/msg129656

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



[issue11339] annotation for class being defined

2011-02-27 Thread Raymond Hettinger

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

This would be an important fix-up if we could find some way to implement it.

The basic problem is that the class object is defined after the class 
definitions have been made, so the target of the Graph reference isn't known 
when the method definitions are being compiled.

One approach to solving this problem is to use a deferred/resolved pattern 
(creating a valid reference to Graph that is visible during method compilation, 
but gets filled-in with the other methods afterwards).

I haven't thought this through completely but think it could be done if we let 
the compiler write to the class dictionary (this is normally off-limits and 
protected by a dict_proxy).  If we let the system punch a hole in the proxy, it 
is possible to resolve deferred class definitions.

Here's a concept sketch:

class Prepared(type):
'Preload the class with a reference to itself'
@classmethod
def __prepare__(mcl, name, bases):
return {name: type(name, bases, {})}
def __new__(mcl, name, bases, mapping):
tmpcls = super().__new__(mcl, name, bases, mapping)
deferred_class = mapping[name]
deferred_class.__dict__.update(tmpcls.__dict__)  # XXX need writeable 
dict_proxy
return deferred_class

class Graph(metaclass=Prepared):

--

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



[issue11339] annotation for class being defined

2011-02-27 Thread Raymond Hettinger

Changes by Raymond Hettinger rhettin...@users.sourceforge.net:


--
Removed message: http://bugs.python.org/msg129657

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



[issue11339] annotation for class being defined

2011-02-27 Thread Raymond Hettinger

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

class Prepared(type):
'Preload the class with a reference to itself'

@classmethod
def __prepare__(mcl, name, bases):
return {name: type(name, bases, {})}

def __new__(mcl, name, bases, mapping):
tmpcls = super().__new__(mcl, name, bases, mapping)
deferred_class = mapping[name]
deferred_class.__dict__.update(tmpcls.__dict__)  # XXX need writeable 
dict_proxy
return deferred_class

class Graph(metaclass=Prepared):
def reverse(self) - Graph:
...

--

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



[issue11339] annotation for class being defined

2011-02-27 Thread Raymond Hettinger

Changes by Raymond Hettinger rhettin...@users.sourceforge.net:


--
Removed message: http://bugs.python.org/msg129659

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



[issue11339] annotation for class being defined

2011-02-27 Thread Raymond Hettinger

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

This would be an important fix-up if we could find some way to implement it.

The basic problem is that the class object is defined after the class 
definitions have been made, so the target of the Graph reference isn't known 
when the method definitions are being compiled.

One approach to solving this problem is to use a deferred/resolved pattern 
(creating a valid reference to Graph that is visible during method compilation, 
but gets filled-in with the other methods afterwards).

I haven't thought this through completely but think it could be done if we let 
the compiler write to the class dictionary (this is normally off-limits and 
protected by a dict_proxy).  If we let the system punch a hole in the proxy, it 
is possible to resolve deferred class definitions.


class Prepared(type):
'Preload the class with a reference to itself'

@classmethod
def __prepare__(mcl, name, bases):
return {name: type(name, bases, {})}

def __new__(mcl, name, bases, mapping):
tmpcls = super().__new__(mcl, name, bases, mapping)
deferred_class = mapping[name]
deferred_class.__dict__.update(tmpcls.__dict__)  # XXX need writeable 
dict_proxy
return deferred_class

class Graph(metaclass=Prepared):
def reverse(self) - Graph:
...

--

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



[issue11339] annotation for class being defined

2011-02-27 Thread Armin Rigo

Changes by Armin Rigo ar...@users.sourceforge.net:


--
nosy:  -arigo

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



[issue11339] annotation for class being defined

2011-02-27 Thread Daniel Urban

Changes by Daniel Urban urban.dani...@gmail.com:


--
nosy: +durban

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



[issue11339] annotation for class being defined

2011-02-27 Thread Raymond Hettinger

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

Until and unless this gets fixed, perhaps we should document some sort of 
workaround.  One possibility is attached.

--
Added file: http://bugs.python.org/file20941/annotations_workaround.py

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



[issue11339] annotation for class being defined

2011-02-26 Thread Andy Harrington

New submission from Andy Harrington ahar...@luc.edu:

You cannot make a self-referential annotation like

class Graph:
def reverse(self) - Graph:
   # ...

This corresponds to a common coding situation.

--
components: Interpreter Core
messages: 129587
nosy: andyharrington
priority: normal
severity: normal
status: open
title: annotation for class being defined
type: feature request
versions: Python 3.3

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



[issue11339] annotation for class being defined

2011-02-26 Thread Benjamin Peterson

Benjamin Peterson benja...@python.org added the comment:

This has been true forever. I suggest you try python-ideas.

--
nosy: +benjamin.peterson
resolution:  - rejected
status: open - closed

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