Mypy: ignoring errors not working (# type: ignore)

Created on 15 Feb 2019  路  3Comments  路  Source: python/mypy

I searched through existing issues, and saw the # type: ignore method, but doesn't seem to work:

from flask import Flask  # type: ignore

app = Flask(__name__)

log = config.configure_logging(app)
log.info('Starting Flask Demo with environment {0}'.format(config.ENVIRONMENT))
app.config.from_object(config)
app.config.from_envvar('APP_SETTINGS', silent=True)

app.config.from_object(config)
app.config.from_envvar('APP_SETTINGS', silent=True)

api/app.py:22: error: "Dict[str, Any]" has no attribute "from_object"
api/app.py:23: error: "Dict[str, Any]" has no attribute "from_envvar"

MyPy Version: 0.670

Most helpful comment

  1. This is a typeshed issue, not mypy issue
  2. It is already fixed in typeshed, wait for next release
  3. # type: ignore should be put on the line where error appears.

All 3 comments

  1. This is a typeshed issue, not mypy issue
  2. It is already fixed in typeshed, wait for next release
  3. # type: ignore should be put on the line where error appears.

thanks that worked,

btw: this was the referenced thread, and # type ignore is on the import

https://github.com/python/mypy/issues/500

Note its# type: ignore (with the colon) as described in PEP-484

Was this page helpful?
0 / 5 - 0 ratings