Skip to content
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

Closed
wants to merge 14 commits into from
Closed

Conversation

CFlaniganMide
Copy link
Contributor

Pull request for python 3.6 style type annotations. Leaving as a draft for now because it breaks compatibility with 3.5.

@StokesMIDE
Copy link
Member

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.

@CFlaniganMide
Copy link
Contributor Author

Agreed, I'm going to leave this as a draft for now. If someone really wants it, this is available.

@codecov-commenter
Copy link

codecov-commenter commented Jul 29, 2021

Codecov Report

Merging #38 (5d652ec) into development (e3f3eef) will increase coverage by 0.08%.
The diff coverage is 100.00%.

Impacted file tree graph

@@               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              
Impacted Files Coverage Δ
ebmlite/core.py 76.92% <100.00%> (+0.03%) ⬆️
ebmlite/decoding.py 91.58% <100.00%> (+0.07%) ⬆️
ebmlite/encoding.py 79.09% <100.00%> (+0.19%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e3f3eef...5d652ec. Read the comment docs.

@CFlaniganMide CFlaniganMide marked this pull request as ready for review July 29, 2021 14:12
@CFlaniganMide CFlaniganMide changed the base branch from master to development July 29, 2021 15:48
Copy link
Member

@StokesMIDE StokesMIDE left a 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] = {}
Copy link
Member

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.

Comment on lines +26 to +28
DEFAULT_FLOAT_SIZE: int = 4 if sys.maxsize <= 2147483647 else 8

LENGTH_PREFIXES: List[int] = [0,
Copy link
Member

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?

Copy link
Contributor Author

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):
Copy link
Member

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.

@StokesMIDE
Copy link
Member

Annotation done in PR #127, closing this one.

@StokesMIDE StokesMIDE closed this Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants