Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
652044c
hack to support "mypy: ignore" comments until the in-built compile fu…
wyattscarpenter Oct 4, 2024
af86125
Use re.sub instead of str.replace, so as to match type ignore behavio…
wyattscarpenter Oct 4, 2024
7831c70
Update fastparse.py: exclude start of line
wyattscarpenter Oct 4, 2024
44242fb
make the re.sub take str or bytes, like the function signature
wyattscarpenter Oct 4, 2024
d697114
use a (?![-_]) to further ignore inline-configs
wyattscarpenter Oct 4, 2024
573125e
use python's tokenize, in order to limit the replacement to only comm…
wyattscarpenter Oct 5, 2024
d3ebf5d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 5, 2024
9d02634
appease the typechecker
wyattscarpenter Oct 5, 2024
8868c63
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 5, 2024
6feee3c
appease shadow rule I guess
wyattscarpenter Oct 5, 2024
6bcdd3f
I guess it's always a string in the comprehension, actually
wyattscarpenter Oct 5, 2024
38d7cbc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 5, 2024
ef13623
implement workaround for \n{{ roundtripping bug
wyattscarpenter Oct 7, 2024
62f034d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 7, 2024
392a37c
refix {{ roundtrip, fix hasattr static check
wyattscarpenter Oct 7, 2024
0bb0886
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 7, 2024
69b0ce7
fix whitespace roundtripping?
wyattscarpenter Oct 7, 2024
8d07bb6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 7, 2024
f319d54
Merge branch 'python:master' into mypy-ignore
wyattscarpenter Oct 7, 2024
6a9b777
Merge branch 'master' into mypy-ignore
wyattscarpenter Jan 13, 2025
23afc30
oh right; I do need io
wyattscarpenter Jan 13, 2025
c0e0171
try adding one test case
wyattscarpenter Jan 13, 2025
069acb9
comments and documentation
wyattscarpenter Jan 13, 2025
461d6e9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 13, 2025
f4990be
fix undefined label: 'inline-configuration' [ref.ref]
wyattscarpenter Jan 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
make the re.sub take str or bytes, like the function signature
  • Loading branch information
wyattscarpenter committed Oct 4, 2024
commit 44242fbd39b77005aa800c11208b51bd8d799fe9
5 changes: 4 additions & 1 deletion mypy/fastparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ def ast3_parse(
) -> AST:
# Hack to support "mypy: ignore" comments until the builtin compile function changes to allow us to detect it otherwise:
# (does not apply at the start of the line to avoid conflicting with mypy file configuration comments https://mypy.readthedocs.io/en/stable/inline_config.html ; see also, util.get_mypy_comments in this codebase)
source = re.sub(r"(?<!^)#\s*mypy:\s*ignore", "# type: ignore", source)
if isinstance(source, str):
source = re.sub(r"(?<!^)#\s*mypy:\s*ignore", "# type: ignore", source)
else:
source = re.sub(rb"(?<!^)#\s*mypy:\s*ignore", b"# type: ignore", source)
return ast3.parse(
source,
filename,
Expand Down
Loading