Skip to content

Commit

Permalink
Update on "[JIT] add support for torch.jit.Final in python 3.6"
Browse files Browse the repository at this point in the history
Python added support for typing.Final in 3.8, and there exists a backport for 3.7 and 3.6 in typing_extensions.Final

The 3.6 version of typing_extensions.Final doesn't support the `getattr(x, '__origin__')` to determine if an object is of the Final type while 3.7 does. This PR allows for the Final type of an object to be discoverable in 3.6


Differential Revision: [D24739402](https://our.internmc.facebook.com/intern/diff/D24739402)

[ghstack-poisoned]
  • Loading branch information
Lilyjjo committed Nov 5, 2020
1 parent 9fb0507 commit cb6e003
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions torch/_jit_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,8 +717,7 @@ def is_rref(ann):

def is_final(ann):
return ann.__module__ in {'typing', 'typing_extensions'} and \
(getattr(ann, '__origin__', None) is Final \
or isinstance(ann, type(Final)))
(getattr(ann, '__origin__', None) is Final or isinstance(ann, type(Final)))

# allows BroadcastingList instance to be subscriptable
class BroadcastingListCls(object):
Expand Down

0 comments on commit cb6e003

Please sign in to comment.