KEMBAR78
Exposes `end_col_offset` attr from python AST by devmessias · Pull Request #12972 · python/mypy · GitHub
Skip to content

Conversation

devmessias
Copy link
Contributor

Description

Closes #12940

The AST nodes from python versions greater than 3.7 provide the end_col_offset attribute. This attribute can be used to solve some issues in mypy.

#12288
#4868
#12513

The AST nodes will have an optional[int] type for end_col_offset attributre.

For python<3.8 this attribute will be None, following the approach already been used in mypy

node.end_line = getattr(n, "end_lineno", None) if isinstance(n, ast3.expr) else None

Test Plan

Currently, the end_line attribute is not being tested in mypy so I believe there is no reason to create a test for end_col_offset.

@github-actions

This comment has been minimized.

@devmessias
Copy link
Contributor Author

Hi @JelleZijlstra. Could you review this PR?

Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Two formatting nits and one question.

@JelleZijlstra JelleZijlstra self-assigned this Jun 16, 2022
devmessias and others added 2 commits June 18, 2022 10:51
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@devmessias
Copy link
Contributor Author

Hi @JelleZijlstra all your suggestions have been implemented.

@JelleZijlstra JelleZijlstra merged commit 1c1f349 into python:master Jun 26, 2022
Gobot1234 pushed a commit to Gobot1234/mypy that referenced this pull request Aug 12, 2022
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provides end_col_offset for mypy ast nodes (pr proposal)

2 participants