Skip to content

mypy tests: Allow per distribution strictness options #1526

Description

@JelleZijlstra

We should try turning on the --disallow-incomplete-defs flag from python/mypy#3744. This can catch issues where we forget type annotations for some function arguments in a stub.

Activity

  1. gvanrossum commented on Aug 7, 2017

    @gvanrossum
    Member

    Good idea.

  2. ilinum commented on Aug 10, 2017

    @ilinum
    Contributor

    I agree :)

    There are a lot of errors (little over 5000).
    Here is the gist with all the errors it produces.

    Not sure if the effort to fix all of them so we can enable the flag is worth it.

  3. OddBloke commented on Aug 17, 2017

    @OddBloke
    Contributor

    Considering only the mypy --python-version 3.6 --strict-optional --disallow-incomplete-defs failures, the breakdown between stdlib/third-party is

    $ cut -d/ -f1 < out | sort | uniq -c
         77 stdlib
        895 third_party

    so enabling this just for the stdlib initially might make addressing them more tractable?

    (Full breakdown by module at https://gist.github.com/OddBloke/dbd78409dcd53bdbb6b3b8571bd29720)

  4. CraftSpider commented on Dec 30, 2019

    @CraftSpider
    Contributor

    I'm interested in tackling at least the stdlib side of this. Would it be better to do this as individual, more well thought-out PRs for each module, or one much larger commit that only does relatively general types

  5. srittau commented on Jan 3, 2020

    @srittau
    Collaborator

    In general, smaller PRs are easier to review, but too many PRs can also become cumbersome. It might be best to have one PR per package if a package has a few changes needed and a few PRs for packages that only have few changes.

  6. hauntsaninja commented on Jun 11, 2020

    @hauntsaninja
    Collaborator

    Note --disallow-untyped-defs is actually stricter than --disallow-incomplete-defs and should be preferred.

  7. srittau commented on Jun 11, 2020

    @srittau
    Collaborator

    I am not sure we should enable either. I prefer to have unannotated types over using Any. I also prefer unannotated types over not having definitions or using "incomplete" markers. Enabling these warnings would raise the bar for contributions, with more complex libraries significantly.

  8. hauntsaninja commented on Jun 11, 2020

    @hauntsaninja
    Collaborator

    I agree on both points! (Although it's reasonable to aspire to turning this on as a lint for stdlib one day, since we're close to completion and hopefully the stdlib isn't changing too drastically).

    My point with the above was just that --disallow-untyped-defs is more in line with what I want for identifying stubs that need improvement (in the stub context, it can be a surprise that --disallow-incomplete-defs doesn't complain about definitions that are missing types entirely). If someone is using these flags to improve typeshed, it's a good thing to know.

  9. srittau commented on Jun 11, 2020

    @srittau
    Collaborator

    Good point about stdlib.

  10. JukkaL commented on Jun 11, 2020

    @JukkaL
    Contributor

    Once we've migrated to modular typeshed, it should be easy to add support for specifying stricness options for each distribution separately in the metadata file. This wouldn't directly help with the stdlib, since stdlib would be distributed as a single entity.

  11. changed the title [-]Perhaps run mypy with --disallow-incomplete-defs[/-] [+]mypy tests: Allow per distribution strictness options[/+] on Sep 17, 2020
  12. srittau commented on Sep 17, 2020

    @srittau
    Collaborator

    I renamed this ticket to what I believe the consensus of the discussion is. Please revert if you don't agree.

  13. removed
    status: deferredIssue or PR deferred until some precondition is fixed
    on Jun 8, 2021
  14. srittau commented on Jun 8, 2021

    @srittau
    Collaborator

    I've removed the "deferred" label as this could now be implemented.

  15. added
    project: infrastructuretypeshed build, test, documentation, or distribution related
    and removed
    project: policyOrganization of the typeshed project
    on Aug 23, 2021
  16. JelleZijlstra commented on Apr 27, 2023

    @JelleZijlstra
    MemberAuthor

    Fixed in #5169

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    project: infrastructuretypeshed build, test, documentation, or distribution related

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions