Comments (5)
With latest mypy, consider passing raise_on_error=True
? Don't think mypy really promises any API here, but feel free to open a PR.
Your escaping is wrong, causing your string literal to be unterminated. This is just the error ast.parse
will give you too, doesn't even need to involve mypy
from mypy.
The errors object is modified on each call to parse, so I have modified parse_str
def parse_str(stub: str) -> Union[MypyFile, str]:
options = Options()
errors = Errors(options)
ast = parse(stub, 'test', None, errors, options)
if 'test' not in errors.error_info_map:
return ast, ''
else:
return ast, errors.error_info_map['test'][0].message
I get an "unterminated string literal" error message but each line in the source code seems to be terminated. I am not sure why.
from mypy.
@hauntsaninja would you mind pointing out where the wrong escaping happens?
from mypy.
\n
from mypy.
Possible solution is to use a raw string. The \n
inside the docstring inside the code sample gets expanded into a newline too early.
from mypy.
Related Issues (20)
- Return type `AsyncIterable` not correctly deduced for abstract methods HOT 2
- Weird error in 1.10.0 trying to parse site-packages\torch\_C\_VariableFunctions.pyi HOT 8
- Regression since mypy 1.7 with functions that return a generic protocol HOT 2
- `safe-super` change breaks Mixin support
- Weird interaction between TypeVar and union
- Tuple of iterables are not narrowed after converting it to tuple of tuple HOT 6
- INTERNAL ERROR from types.py: assert isinstance(visitor, SyntheticTypeVisitor)
- Difference in behaviour between overload and TypeVars when using functools.update_wrapper
- False error: Never has no attribute "foo" [attr-defined]
- stubgen: combine `--include-docstrings` and typeshed
- Type invalid due to import, only on alternating runs HOT 1
- Setting python_executable in $XDG_CONFIG_HOME/mypy/config does not work HOT 2
- Crash on a tricky overloaded Protocol
- Using unpack to keep parameters when creating httpx subclass leads to crash
- namespace package import error is order-dependent and not silenceable with `ignore_missing_imports` HOT 3
- Conditional decorated functions are not type checked
- Crash Applying Generic Arguments
- Wrong Metaclass Conflict Error
- Detect if shell is in activated virtual environment, but mypy is not installed in it.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mypy.