Skip to content

Ignore specific error codes from configuration file #9533

Closed

Description

@amikrop

Please make it possible to ignore errors with arbitrary error codes, though the configuration file.
Essentially, make the # type: ignore[code, ...] behavior possible through the configuration file, as it would be
nice to have the ability to keep the code visually simpler, by moving these directives from comments, to the
config file.

Activity

  1. gvanrossum commented on Oct 5, 2020

    @gvanrossum
    Member

    You can do it from the command line, e.g. --disable-error-code attr-defined.

    IIUC you can do it from the config file too (disable-error-code = attr-defined) -- it just needs documenting.

  2. hauntsaninja commented on Oct 5, 2020

    @hauntsaninja
    Collaborator

    (Note this feature hasn't made it to a mypy release yet, so you'll need to install mypy from git master to do this)

  3. amikrop commented on Oct 5, 2020

    @amikrop
    ContributorAuthor

    Alright, thanks for your answers.

  4. gvanrossum commented on Oct 5, 2020

    @gvanrossum
    Member

    Keeping this open because it needs docs.

  5. gvanrossum commented on Oct 5, 2020

    @gvanrossum
    Member

    Whoops, trying this with master, it looks like there's a bug in the code that reads this flag from mypy.ini.

    usage: mypy [-h] [-v] [-V] [more options; see below]
                [-m MODULE] [-p PACKAGE] [-c PROGRAM_TEXT] [files ...]
    mypy: error: Invalid error code(s): i, m, o, p, r, t
    

    The line in mypy.ini was

    disable_error_code = import
    
  6. amikrop commented on Oct 5, 2020

    @amikrop
    ContributorAuthor

    Installed a git checked out version of mypy to try this. The command-line way worked (for one or more error codes), but the config file way did not:
    mypy: error: Invalid error code(s): i, m, o, p, r, t
    Other list-receiving options, as always_true did not have this problem.
    Printing options.disable_error_code in main.py:process_options gave this:
    ['i', 'm', 'p', 'o', 'r', 't']
    which is strange, because the --disable-error-code argument is added to the parser exactly the same way others (like --always-true) do.
    I think the mypy.ini file is not malformed:
    [mypy]
    always_true = foo, bar
    disable_error_code = import

    Python 3.8.5

    Just saw you found out already by yourself :)

    Trying to debug this myself, but in case somebody else does before me, I would be interested to know the cause of this.

  7. gvanrossum commented on Oct 5, 2020

    @gvanrossum
    Member

    Probably something's needed to flag that config option as a list. I'd be grateful if you debugged this and came up with a fix!

  8. amikrop commented on Oct 5, 2020

    @amikrop
    ContributorAuthor

    Working on it.
    Edit: done
    #9537

  9. Nikhil1O1 commented on Oct 6, 2020

    @Nikhil1O1

    @gvanrossum can I work on the documenting this thing??

  10. gvanrossum commented on Oct 6, 2020

    @gvanrossum
    Member

    @Nikhil1O1

    @gvanrossum can I work on the documenting this thing??

    Please do!

  11. hauntsaninja commented on Oct 6, 2020

    @hauntsaninja
    Collaborator

    I think we actually have documentation for this; both CLI and config are now documented. (But documentation can almost always be improved, so if you see improvements to be made, feel free to suggest them!)

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions