Skip to content

fast parser: # type: ignore should ignore non-* imports entirely #1739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rwbarton opened this issue Jun 22, 2016 · 2 comments
Closed

fast parser: # type: ignore should ignore non-* imports entirely #1739

rwbarton opened this issue Jun 22, 2016 · 2 comments

Comments

@rwbarton
Copy link
Contributor

The parse_file function from the old parser does this:

        # Skip imports that have been ignored (so that we can ignore a C extension module without
        # stub, for example), except for 'from x import *', because we wouldn't be able to
        # determine which names should be defined unless we process the module. We can still
        # ignore errors such as redefinitions when using the latter form.
        imports = [node for node in self.imports
                   if node.line not in self.ignored_lines or isinstance(node, ImportAll)]
        node = MypyFile(defs, imports, is_bom, self.ignored_lines,
                        weak_opts=weak_opts)

The effect is that a # type: ignore comment on an import statement doesn't just silence errors on that line, but also prevents mypy from trying to process the imported module at all.

The fast parser should do the same thing.

@rwbarton
Copy link
Contributor Author

Actually I may just fix this as a side effect of #1695.

rwbarton added a commit to rwbarton/mypy that referenced this issue Jun 22, 2016
This commit also simplifies the handling of ignored_lines slightly,
setting them once in the Errors object for each file file after it is
parsed.

Fixes python#1345 and python#1739.
gvanrossum pushed a commit that referenced this issue Jun 22, 2016
This commit also simplifies the handling of ignored_lines slightly,
setting them once in the Errors object for each file file after it is
parsed.

Fixes #1345 and #1739.
@rwbarton
Copy link
Contributor Author

Fixed by #1695.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant