Repository navigation
Conversation
Codecov Report
@@ Coverage Diff @@
## main #947 +/- ##
==========================================
- Coverage 68.75% 68.75% -0.01%
==========================================
Files 63 63
Lines 9437 9440 +3
==========================================
+ Hits 6488 6490 +2
- Misses 2949 2950 +1
Continue to review full report at Codecov.
|
|
New to this - should I reformat formatter.py with black and resubmit the code? |
|
Looks like you got it, thank you! Sorry for the delay here.
I like the second one better, that seems truer to the code as it's currently written. Feel free to change the code though if it's easier to type, e.g. using a new temp variable or adding a new "if t is None" bailout. |
|
Thanks, @thomasballinger. I think the only way to avoid using At least, that's how it seems to me. I'll try another commit with a temp variable and you can make the call. I'm probably using too much of your time on the little details, but I appreciate the help! |
|
@thomasballinger, is there anything else I need to do with this PR at this point? |
|
Sorry about the delay, pinging with that comment was the perfect action. I'll look into this more this morning, right now when I run mypy locally I'm getting which I'm sure it just my problem since it works in CI. Once I get this sorted (no action needed from you) I'll merge this. |
|
I have to change the typing of I could imagine a reason for this: according to the types, it's not safe to include both |
|
Merged, thank you @Ben-Reg! |
Adding type hints to formatter.py.
A note on line 128.
token = token.parentcauses some problems with mypy becausetokenis type_TokenTypewhiletoken.parentisOptional[_TokenType]The easy solution that I used below was to type
tokensourcelike so:tokensource: Iterable[MutableMapping[Any, str]]Another approach would be something like this:
t: Optional[_TokenType] = tokent = t.parentIf we do it that way, we can type
tokensourcemore accurately:tokensource: Iterable[MutableMapping[_TokenType, str]]