Skip to content

Conversation

@hukkin
Copy link
Contributor

@hukkin hukkin commented Apr 28, 2021

No description provided.

@codecov
Copy link

codecov bot commented Apr 28, 2021

Codecov Report

Merging #160 (c88c34d) into master (53d9b33) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #160   +/-   ##
=======================================
  Coverage   96.10%   96.10%           
=======================================
  Files          60       60           
  Lines        3232     3232           
=======================================
  Hits         3106     3106           
  Misses        126      126           
Flag Coverage Δ
pytests 96.10% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
markdown_it/common/utils.py 74.35% <100.00%> (ø)

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 53d9b33...c88c34d. Read the comment docs.



def charCodeAt(src: str, pos: int):
def charCodeAt(src: str, pos: int) -> Any:
Copy link
Contributor Author

@hukkin hukkin Apr 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Any return type is to explicitly keep disabling type checking for the return value. This because the None case is pretty painful and dynamic: it happens when pos >= len(src) but in code, before calling the function, we always have dynamic checks to ensure this doesn't happen. Thus the proper Optional[int] annotation requires many ugly cast(int, ...)s.

Best would be to raise IndexError instead of returning None, but I guess that isn't true to JS upstream, so IMO this is the second best option.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeh I'm not picking at that thread right now 😬

@chrisjsewell chrisjsewell merged commit c55a243 into executablebooks:master Apr 29, 2021
@hukkin hukkin deleted the type-annotate-common-utils branch April 29, 2021 00:31
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.

3 participants