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
Marking constants as Final #208
Conversation
Codecov Report
@@ Coverage Diff @@
## 3.0 #208 +/- ##
==========================================
+ Coverage 90.05% 90.08% +0.03%
==========================================
Files 11 11
Lines 1166 1170 +4
==========================================
+ Hits 1050 1054 +4
Misses 116 116
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
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.
We are close to the margin error regarding the performance gap. Using Final does not strike me as useful now.
I am considering dropping Python 3.6 but certainly not 3.7 and adding a mandatory dependency in order to exploit "Final" is a hard no for me.
from codecs import BOM_UTF8, BOM_UTF16_BE, BOM_UTF16_LE, BOM_UTF32_BE, BOM_UTF32_LE | ||
from encodings.aliases import aliases | ||
from re import IGNORECASE, compile as re_compile | ||
from typing import Dict, List, Set, Union | ||
|
||
if sys.version_info < (3, 8): |
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.
Adding a mandatory dependency for a single typing annotation bugs me.
@@ -8,3 +8,4 @@ black==22.6.0 | |||
flake8==5.0.4 | |||
mypy==0.971 | |||
isort | |||
typing_extensions |
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.
The test passes only because it requires installing all dev reqs. In live mode, it would crash because typing_ext is not found.
From mypy docs:
You can use the typing.Final qualifier to indicate that a name or attribute should not be reassigned, redefined, or overridden. This is often useful for module and class level constants as a way to prevent unintended modification. Mypy will prevent further assignments to final names in type-checked code:
Testing after mypy compiling:
Before commit:
After commit: