Skip to content

Commit

Permalink
[JIT] add support for torch.jit.Final in python 3.6
Browse files Browse the repository at this point in the history
ghstack-source-id: 9928d3f32dffd4ea07d8493c3cd81e7e279533e0
Pull Request resolved: #47393
  • Loading branch information
Lilyjjo committed Nov 5, 2020
1 parent e4bc785 commit a7fa1ab
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 0 additions & 2 deletions test/jit/test_recursive_script.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import unittest
import os
import sys
import typing
Expand Down Expand Up @@ -159,7 +158,6 @@ def a(x):
# Make sure that no entries are left over from the previous failure
FileCheck().check_count("is being compiled", 2).run(str(e))

@unittest.skipIf(sys.version_info[:2] < (3, 7), "Class annotations are a thing in > 3.5, need to fix for < 3.7")
def test_constants_with_final(self):
class M1(torch.nn.Module):
x : torch.jit.Final[int]
Expand Down
2 changes: 1 addition & 1 deletion torch/_jit_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ def is_rref(ann):

def is_final(ann):
return ann.__module__ in {'typing', 'typing_extensions'} and \
(getattr(ann, '__origin__', None) is 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 a7fa1ab

Please sign in to comment.