| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Awesome. I think it could worth replacing some of these with asserts, just in case there's something mypy has got wrong
Sorry, something went wrong.
Do you have some specific items in mind? I can surely add asserts where needed. |
Sorry, something went wrong.
I actually just did this too! I ended up with quite a few asserts so maybe that can be a second opinion. master...A5rocks:mypy:experiments/warn_unreachable (I also deferred on mypy_extensions.trait subclassing instead of updating the isinstance) Though that branch also passes mypy's test suite, so maybe that's a sign that actually those asserts aren't necessary at all and mypy was correct. |
Sorry, something went wrong.
There was a problem hiding this comment.
I'm generally unsure about the isinstance(x, FuncBase) changes where x: Node (and similar mypy_extensions.trait workarounds) because it seems like that just uses tuples to work around reachability? I haven't tried some testcases locally so I'm not entirely sure though.
Sorry, something went wrong.
| assert sys.platform == "win32" | ||
| if sys.platform == "win32": | ||
| assert sys.platform == "win32", "Running not on Windows" | ||
| if sys.platform == "win32": # needed to find win specific sys apis |
There was a problem hiding this comment.
You can un-indent this.
Sorry, something went wrong.
There was a problem hiding this comment.
Nope, sadly I can't :(
Looks like that mypy does not narrow sys.platform after assert (this might be a bug).
Sorry, something went wrong.
There was a problem hiding this comment.
But, I added assert False in the end instead, it is more readable now.
Sorry, something went wrong.
There was a problem hiding this comment.
Nope, sadly I can't :( Looks like that mypy does not narrow sys.platform after assert (this might be a bug).
Huh I was able to. But I guess that might just be because I was testing on Windows.
Sorry, something went wrong.
There was a problem hiding this comment.
Yes, you need to set platform = win32 or platform = linux manually in .ini file for that.
Sorry, something went wrong.
Sorry, I don't understand your question. Can you please provide an example? |
Sorry, something went wrong.
I was confused, actually. I've now read the docstring of FuncBase and I get why you switched out the isinstance checks... Except it refers to an issue that's closed! You're just doing #13607 (comment) (3), which will mean we have to revert a bunch of lines whenever we actually fix the issue (1). IMO we should fix the issue at hand but continuing with (3) is OK as long as you update the comment around SYMBOL_FUNCBASE_TYPES (and maybe put a TODO or something there?). |
Sorry, something went wrong.
|
I will leave this open for a couple of days to give an opportunity for second rounds of reviewes, and merge on Wen or so :) Thanks, @A5rocks! |
Sorry, something went wrong.
|
|
||
|
|
||
| def normalize_path_separators(path: str) -> str: | ||
| if sys.platform == "win32": |
There was a problem hiding this comment.
If #18539 or a similar fix is merged, then this change should no longer be necessary I believe.
Sorry, something went wrong.
|
Going to merge #18523 later tomorrow, if no one objects |
Sorry, something went wrong.
|
Diff from mypy_primer, showing the effect of this PR on open source code: freqtrade (https://github.com/freqtrade/freqtrade): 1.95x slower (129.1s -> 252.2s in a single noisy sample)
|
Sorry, something went wrong.
This check prooved to be useful, since it find a lot of dead / incorrect code. Closes python#18079 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
| Back | FazBrowse Home | New Git URL |
This check prooved to be useful, since it find a lot of dead / incorrect code.
Closes #18079