New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JIT] add support for torch.jit.Final in python 3.6 #47393
Conversation
[ghstack-poisoned]
ghstack-source-id: 14af2951e99cb236505356ef80c0eb34a901cd09 Pull Request resolved: #47393
Codecov Report
@@ Coverage Diff @@
## gh/Lilyjjo/11/base #47393 +/- ##
======================================================
+ Coverage 81.26% 81.47% +0.20%
======================================================
Files 1792 1792
Lines 186142 186142
======================================================
+ Hits 151275 151657 +382
+ Misses 34867 34485 -382 |
@@ -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))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional:
Can you say a bit more about why this change is needed (in PR description)? I am curious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added :)
Do we need a test for this? I think the issue that reported this issue has a small test case we can use. |
Differential Revision: [D24739402](https://our.internmc.facebook.com/intern/diff/D24739402) [ghstack-poisoned]
ghstack-source-id: 1a9a181c0b899598621bfaa226e653e857fe80b1 Pull Request resolved: #47393
💊 CI failures summary and remediationsAs of commit cb6e003 (more details on the Dr. CI page): ✅ None of the CI failures appear to be your fault 💚
🚧 1 fixed upstream failure:These were probably caused by upstream breakages that were already fixed.
Please rebase on the
|
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]
ghstack-source-id: 9928d3f32dffd4ea07d8493c3cd81e7e279533e0 Pull Request resolved: #47393
@@ -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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this comment was out of date? Not totally sure, but this test now passes for python3.6 and python3.7 and checks the functionality of Final
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]
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]
ghstack-source-id: 9928d3f32dffd4ea07d8493c3cd81e7e279533e0 Pull Request resolved: #47393
Stack from ghstack:
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.6Differential Revision: D24739402