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

List and dict literals with explicit types not documented #1

Closed
JukkaL opened this issue Dec 8, 2012 · 1 comment
Closed

List and dict literals with explicit types not documented #1

JukkaL opened this issue Dec 8, 2012 · 1 comment

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Dec 8, 2012

The mypy language overview should mention list and dict literals with explicit types, for example:

names = <str> []  # Equivalent to str[] names = []
counts = <str, int> {}  # Equivalent to dict<str, int> counts = {}
@JukkaL
Copy link
Collaborator Author

JukkaL commented Dec 20, 2012

Updated the language overview.

@JukkaL JukkaL closed this as completed Dec 20, 2012
JukkaL added a commit that referenced this issue Jul 24, 2014
Add support for modeling unary plus, including with respect to a custom __pos__
cdce8p referenced this issue in cdce8p/mypy Oct 24, 2020
Added testcases for pep585ga
ichard26 added a commit to ichard26/mypy that referenced this issue Mar 17, 2023
Change how imports (not from imports!) are processed so they can be
table-driven and compact. Here's how it works:

Import nodes are divided in groups (in the prebuild visitor). Each group
consists of consecutive Import nodes:

  import mod         <| group python#1
  import mod2         |

  def foo() -> None:
      import mod3    <- group python#2

  import mod4        <- group python#3

Every time we encounter the first import of a group, build IR to call
CPyImport_ImportMany() that will perform all of the group's imports in
one go.

Previously, each module would imported and placed in globals manually
in IR, leading to some pretty verbose code.

The other option to collect all imports and perform them all at once in
the helper would remove even more ops, however, it's problematic for
the same reasons from the previous commit (spoiler: it's not safe).

Implementation notes:

  - I had to add support for loading the address of a static directly,
    so I shoehorned in LoadLiteral support for LoadAddress.

  - Unfortunately by replacing multiple nodes with a single function
    call at the IR level, the traceback line number is static. Even if
    an import several lines down a group fails, the line # of the first
    import in the group would be printed.

    To fix this, I had to make CPyImport_ImportMany() add the traceback
    entry itself on failure (instead of letting codegen handle it
    automatically). This is admittedly ugly.
ilevkivskyi added a commit that referenced this issue Aug 9, 2023
#15832)

…5272)"

This reverts commit 2aaeda4.

<!-- If this pull request fixes an issue, add "Fixes #NNN" with the
issue number. -->

(Explain how this PR changes mypy.)

<!--
Checklist:
- Read the [Contributing
Guidelines](https://github.com/python/mypy/blob/master/CONTRIBUTING.md)
- Add tests for all changed behaviour.
- If you can't add a test, please explain why and how you verified your
changes work.
- Make sure CI passes.
- Please do not force push to the PR once it has been reviewed.
-->
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