-
Notifications
You must be signed in to change notification settings - Fork 4
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
Feature/type annotations #38
Conversation
It looks like 25% of Python 3 users are still using versions earlier than 3.6; since type annotation is just unenforced syntactic sugar, I'd like to hold off until almost everyone is using 3.6 or newer. When the numbers improve, we can make the change - after documenting which ebmlite versions are compatible with which Python versions. |
Agreed, I'm going to leave this as a draft for now. If someone really wants it, this is available. |
# Conflicts: # ebmlite/util.py
…nnotations # Conflicts: # ebmlite/core.py
Codecov Report
@@ Coverage Diff @@
## development #38 +/- ##
===============================================
+ Coverage 61.77% 61.86% +0.08%
===============================================
Files 12 12
Lines 1308 1311 +3
===============================================
+ Hits 808 811 +3
Misses 500 500
Continue to review full report at Codecov.
|
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.
Is the mypy
and .pyi
stuff still required if we're doing standard Python 3.5 typing?
os.path.realpath(os.path.dirname(schemata.__file__))] | ||
|
||
# SCHEMATA: A dictionary of loaded schemata, keyed by filename. Used by | ||
# `loadSchema()`. In most cases, SCHEMATA should not be otherwise modified. | ||
SCHEMATA = {} | ||
SCHEMATA: Dict[Union[str, bytes, bytearray], Any] = {} |
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 the keys will always be string.
DEFAULT_FLOAT_SIZE: int = 4 if sys.maxsize <= 2147483647 else 8 | ||
|
||
LENGTH_PREFIXES: List[int] = [0, |
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.
Do internally-used constants need typing?
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 probably got a little over-zealous when I originally did this, honestly.
@@ -218,7 +219,7 @@ def encodeBinary(val, length=None): | |||
(len(val), length)) | |||
|
|||
|
|||
def encodeString(val, length=None): | |||
def encodeString(val: ByteString, length: Optional[int] = None): |
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.
Should also include str
... from the EBML spec, the subset-of-ASCII limitation is on the storage, and the data is still considered to be strings.
Annotation done in PR #127, closing this one. |
Pull request for python 3.6 style type annotations. Leaving as a draft for now because it breaks compatibility with 3.5.