Skip to content
Branch: release-0.710
Commits on Jun 19, 2019
  1. Document --new-semantic-analyzer (#7023)

    JukkaL authored and gvanrossum committed Jun 19, 2019
  2. Bump version to 0.710

    gvanrossum committed Jun 19, 2019
Commits on Jun 18, 2019
  1. New semantic analyzer: fix ambiguity between submodule and local defi…

    JukkaL authored and gvanrossum committed Jun 18, 2019
    …nition (#7017)
    Now imports are biased to target the submodule of current package
    target, but elsewhere a local definition with the same name as a
    submodule takes precedence.  Even though this doesn't quite reflect
    what happens at runtime, this seems to cover the typical use cases
    well, and the implementation is simple.
    Fixes #6828.
  2. Sync mypy with recent runtime updates in typing (#7013)

    ilevkivskyi authored and gvanrossum committed Jun 18, 2019
    This introduces the following updates:
    * Allow using `typing.TypedDict` (still support all the old forms)
    * Add a test for `typing.Literal` (it was already supported, but there were no tests)
    * Rename `@runtime` to `@runtime_checkable`, while keeping the alias in `typing_extensions` for backwards compatibility.
    (Note that `typing.Final` and `typing.Protocol` were already supported and there are tests.)
    See also python/typeshed#3070
  3. Use level "note" for reveal_type and reveal_locals (#6919)

    blueyed authored and gvanrossum committed Jun 18, 2019
    Tests were fixed using:
    - sed -i 's/# E: Revealed type/# N: Revealed type/g' test-data/**/*.test
    - sed -i 's/: error: Revealed type/: note: Revealed type/g' test-data/**/*.test
    Fixes #6901.
Commits on Jun 17, 2019
  1. Sync typeshed (#7010)

    gvanrossum committed Jun 17, 2019
  2. New semantic analyzer: don't add submodules to symbol tables (#7005)

    JukkaL committed Jun 17, 2019
    Previously we added each submodule implicitly to the the symbol table of
    the parent package. This PR removes this and instead we look up names from
    the modules dictionary if they aren't found in the symbol table. The change
    only affects the new semantic analyzer.
    This provides a foundation that should make #6828 much easier to address. It 
    also arguably cleans up the code.
    Also refactor some related code to avoid duplication.
    This isn't a pure refactor since some error messages are slightly different.
  3. Fix typo in config README (#7007)

    emilgoldsmith authored and ilevkivskyi committed Jun 17, 2019
Commits on Jun 14, 2019
  1. Mark TypedDict as not experimental (#6994)

    JukkaL committed Jun 14, 2019
    It's no longer experimental since PEP 589 was accepted:
  2. Make `narrow_declared_type` correctly handle Literal types (#6961)

    Michael0x2a committed Jun 14, 2019
    This diff fixes the `narrowed_declared_type` function to correctly
    handle cases where the declared type is actually a `Literal[...]`.
    Specifically, doing something like the below will return `int` instead
    of `Literal[42]`:
        narrowed_declared_type(Literal[42], int)
    This is inconsistent with the behavior of doing something like the
    below, which will return `ChildType`:
        narrowed_declared_type(ChildType, ParentType)
    This diff modifies `narrowed_declared_type` to instead return `Literal[42]`
    in the first example.
Commits on Jun 13, 2019
  1. New semantic analyzer: Keep explicit type and inferred status in sync (

    ilevkivskyi committed Jun 13, 2019
    This is (kind of) an actual fix for #6952
    The problem is that previously `unwrap_final()` unconditionally set `s.type` to `None` for bare `Final`, even if the type was inferred from a simple literal r.h.s. on a previous iteration. At the same time `lvalue.is_inferred_def` remained `False`, so that the type was not inferred on the second iteration.
    This way `s.type` and `lvalue.is_inferred_def` may get out of sync depending on the number of iterations, thus causing weird behavior in type checker.
    I generally can say the current way of storing the inferred status is error-prone, but we already have #6458 to track this.
  2. Fix type annotation for AugmentedHelpFormatter (#6982)

    msullivan committed Jun 13, 2019
    This fixes a crash under mypyc.
    Closes #6980.
  3. New semantic analyzer: fix order=True in dataclass with deferral (#6987)

    JukkaL authored and ilevkivskyi committed Jun 13, 2019
    Fixes #6954.
  4. Specify return types for the return types incompatible with supertype…

    joejuzl authored and ilevkivskyi committed Jun 13, 2019
    … error (#6979)
    Fixes #2797
  5. New semantic analyzer: fix crash related to dataclasses.InitVar (#6984)

    JukkaL committed Jun 13, 2019
    Previously InitVar attributes were missing on the second semantic
    analysis pass, since the dataclasses plugin removes those attributes
    from the class symbol table. This caused a crash. The fix is to reset
    the attribute declarations so that they will be re-added to the symbol
    table on successive semantic analysis passes.
    Fixes #6955.
  6. New semantic analyzer: track line numbers of placeholders (#6983)

    JukkaL committed Jun 13, 2019
    Line numbers are used sometimes to decide when a name should be looked
    up from an outer scope, so they should be set for placeholders.
    This actually breaks some forward references to assignment-based named
    tuples. The reason is that we don't set `becomes_typeinfo=True` for
    the placeholders. I'm going to open a separate issue about this, as
    it's an existing issue and this change only exposes it.
    Fixes #6949.
  7. Add test case for class variable forward reference (#6974)

    JukkaL committed Jun 13, 2019
    This is broken with the old semantic analyzer but works with the new
    semantic analyzer.
    Closes #4760.
  8. Add test case for global declaration without initializer (#6975)

    JukkaL committed Jun 13, 2019
    This crashes on old semantic analyzer but doesn't crash when
    using the new semantic analyzer.  The error message is pretty
    poor but that's better than crashing.
    Closes #5923.
  9. Fix crashes with callable() and issubclass() (#6981)

    JelleZijlstra authored and ilevkivskyi committed Jun 13, 2019
    This fixes two possible crashes I noticed while reading the code.
Commits on Jun 12, 2019
  1. Keep track of fstring conversions and format-specs (#6965)

    SanjitKal authored and msullivan committed Jun 12, 2019
    Modify to keep track of format specifiers and conversions for f-strings. 
    Currently, braces values within f-strings are just converted to calls to format,
    ignoring format specifiers and conversions ('{}'.format(...)). 
    With this the information regarding format specifiers and conversions are passed along to format.
    To accomodate format specifiers with expressions evaluated at runtime, we pass the
    format specifier as an argument also (ex: '{!r{}}.format(..., "<30")').
    Note that format specifiers can contain expressions that are evaluated at runtime.
    Keeping track of this information is needed in order to provide mypyc with enough information to support fstrings with format specifiers and conversions.
  2. Sync typeshed (#6977)

    JukkaL committed Jun 12, 2019
  3. New analyzer: resolve name clashes between generated and existing nod…

    ilevkivskyi authored and JukkaL committed Jun 12, 2019
    …es (#6972)
    Fixes #6454.
    Fixes #6973.
    Note that the solution doesn't guarantee the order of numbers N in 
    foo-redefinitionN coincides with the textual order of nodes. But it looks 
    like we don't need this for anything.
Commits on Jun 11, 2019
  1. Allow class-based TypedDicts in all python versions (#6971)

    msullivan committed Jun 11, 2019
    Entries can't be *declared* in versions that don't support type
    annotations, of course, but class-based TypedDict still serves a
    valuable purpose in merging TypedDicts together.
    This error *only* triggers on empty TypedDicts, since any non-empty
    ones would have failed earlier with a syntax error. So there is no
    reason to prohibit it because we can handle that case totally fine.
  2. New semantic analyzer: enable remaining tests and fix issues (#6969)

    JukkaL committed Jun 11, 2019
    This enables incremental mode tests for the new semantic analyzer. Some
    tests are skipped, mostly because of issues related to recursive type
    definitions and plugins.
    Also fix some issues related to type aliases and recursive definitions.
    Remove support for skipping test files when using the new semantic
  3. Enable additional tests on new semantic analyzer (#6970)

    JukkaL committed Jun 11, 2019
    Some tests are only enabled for the new semantic analyzer. For a few
    I decided to create duplicate tests, but only if the test seemed
    worthwhile enough, as the old semantic analyzer isn't going to change
    much any more.
Commits on Jun 10, 2019
  1. Use new semantic analyzer for bootstrap (#6966)

    ilevkivskyi committed Jun 10, 2019
    This also updates mypyc pin to the latest version that works well with new analyzer.
  2. Suggest trying master branch on crash (#6934)

    ethanhs authored and JukkaL committed Jun 10, 2019
Commits on Jun 9, 2019
  1. Document mypy as "beta" instead of "alpha" software (#6962)

    Michael0x2a committed Jun 9, 2019
    In #6740, I think we all pretty
    much unanimously agreed mypy ought to be labeled as "beta" at the
    absolute minimum.
    So, might as well just do the switch now.
Commits on Jun 7, 2019
  1. New semantic analyzer: fix access to imported name in class body (#6943)

    JukkaL committed Jun 7, 2019
    We shouldn't use the line number of an imported name to decide
    whether it's defined when the line number refers to another
  2. Use interable unpacking now that mypyc supports it (#6946)

    msullivan authored and ilevkivskyi committed Jun 7, 2019
Commits on Jun 5, 2019
  1. New semantic analyzer: fix falling back to outer scope in class body (#…

    JukkaL committed Jun 5, 2019
    This fixes scoping issue where code like this was rejected:
    c: C  # Forces second semantic analysis pass
    class X: pass
    class C:
        X = X   # Should be no error here
    The approach is to fall back to the outer scope if the definition
    in the class body is not ready yet, based on the line numbers of
    the definitions.
    Additionally generate an error for references to names defined 
    later in a class body.
    This only addresses class bodies. Local scopes have a similar 
    issue with references to undefined names. I'm planning to 
    address that in a separate PR.
    The basic fix is very simple, but various other changes were
    required to support multi-line definitions and certain edge cases.
    Work towards #6303.
  2. Update typed_ast dep to 1.4.0+ (#6937)

    gvanrossum committed Jun 5, 2019
    Now that typed_ast 1.4.0 is released (whose main new feature is support for extra text after # type: ignore).
Commits on Jun 4, 2019
  1. Add --no-implicit-reexport flag (#6562)

    jhance authored and ilevkivskyi committed Jun 4, 2019
    Adds a --no-implicit-reexport flag, intended for giving modules the same behavior as stubs for re-exporting their imports.
    The goal is to make it possible to prevent bad transitive imports from causing dependency issues. And to make it easier to move things to a different module.
  2. Use new semantic analyzer in self check (#6932)

    JukkaL committed Jun 4, 2019
    It's good to dogfood new features before release.
You can’t perform that action at this time.