Skip to content
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

AST nodes for PEP 695 type param syntax do not require end_lineno nor end_col_offset #106145

Closed
jacobtylerwalls opened this issue Jun 27, 2023 · 4 comments
Assignees
Labels
3.12 bugs and security fixes 3.13 bugs and security fixes topic-parser topic-typing type-bug An unexpected behavior, bug, or error

Comments

@jacobtylerwalls
Copy link
Contributor

jacobtylerwalls commented Jun 27, 2023

Bug report

Unlike AST nodes for 3.10 match syntax, AST nodes for 3.12 type param syntax (PEP 695) do not require end_lineno nor end_col_offset.

For 3.10 match syntax, this question was discussed here, and it was decided to require them.

Context: see end_lineno and end_col_offset creation in 3.8 by #11605.

cpython/Parser/Python.asdl

Lines 148 to 151 in bb578a0

type_param = TypeVar(identifier name, expr? bound)
| ParamSpec(identifier name)
| TypeVarTuple(identifier name)
attributes (int lineno, int col_offset, int? end_lineno, int? end_col_offset)

Your environment

Python 3.12.0b3

Linked PRs

@jacobtylerwalls jacobtylerwalls added the type-bug An unexpected behavior, bug, or error label Jun 27, 2023
@Eclips4
Copy link
Member

Eclips4 commented Jun 27, 2023

cc @JelleZijlstra

@AlexWaygood AlexWaygood added topic-typing 3.12 bugs and security fixes 3.13 bugs and security fixes topic-parser labels Jun 27, 2023
@JelleZijlstra
Copy link
Member

Good catch, I think we should fix this. Feel free to submit a PR; otherwise I should get to it in the next few days.

@sobolevn
Copy link
Member

sobolevn commented Jun 29, 2023

Sorry for sliding in, but I was experimenting with type_params support for my linter and found this related issue :)

miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jun 30, 2023
…am` nodes (pythonGH-106224)

(cherry picked from commit 46c1097)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
JelleZijlstra pushed a commit that referenced this issue Jul 1, 2023
…ram` nodes (GH-106224) (#106295)

gh-106145: Make `end_{lineno,col_offset}` required on `type_param` nodes (GH-106224)
(cherry picked from commit 46c1097)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
@jacobtylerwalls
Copy link
Contributor Author

Fixed in #106224. Thanks all!

manosriram pushed a commit to manosriram/cpython that referenced this issue Jul 1, 2023
jacobtylerwalls added a commit to jacobtylerwalls/astroid that referenced this issue Jul 31, 2023
These attributes cannot be none in real-world situations,
see python/cpython#106145.
jacobtylerwalls added a commit to pylint-dev/astroid that referenced this issue Jul 31, 2023
These attributes cannot be none in real-world situations,
see python/cpython#106145.
mbyrnepr2 pushed a commit to mbyrnepr2/astroid that referenced this issue Aug 2, 2023
These attributes cannot be none in real-world situations,
see python/cpython#106145.
Pierre-Sassoulas pushed a commit to pylint-dev/astroid that referenced this issue Aug 5, 2023
…s__ container (#2263)

* Exclude type-annotated class attributes, which have no assigned value, from the ``__members__`` container of an ``Enum`` class.

Refs pylint-dev/pylint#7402

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix exising test.

The value if now `Uninferable` in the case of
an annotated attribute of an `enum.Enum` class with no assigned value.

* Update astroid/brain/brain_namedtuple_enum.py

Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>

* Update tests.

* Update test: Use `infer()` instead of `inferred()`.

* Update type annotations of PEP 695 nodes (#2264)

These attributes cannot be none in real-world situations,
see python/cpython#106145.

* Update sphinx requirement from ~=7.0 to ~=7.1 (#2265)

Updates the requirements on [sphinx](https://github.com/sphinx-doc/sphinx) to permit the latest version.
- [Release notes](https://github.com/sphinx-doc/sphinx/releases)
- [Changelog](https://github.com/sphinx-doc/sphinx/blob/master/CHANGES)
- [Commits](sphinx-doc/sphinx@v7.0.0...v7.1.1)

---
updated-dependencies:
- dependency-name: sphinx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Ensure a node is inferred in the case when there is only one member.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Undo unintended changes.

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 bugs and security fixes 3.13 bugs and security fixes topic-parser topic-typing type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

6 participants
@JelleZijlstra @sobolevn @jacobtylerwalls @AlexWaygood @Eclips4 and others