mypy overrides in toml are ignored?

2024/10/3 21:26:22

The following is a simplified version of the toml file example from the mypy documentation:

[tool.mypy]
python_version = "3.7"
warn_return_any = true
warn_unused_configs = true[[tool.mypy.overrides]]
module = ["somelibrary"]
ignore_missing_imports = true

I am using this configuration in a project where I have a third party library (here named "somelibrary") that is missing type hints and thus causes a lot of spam in the mypy report.

The global mypy configuration is picked up, so I know the overall setup is fine, but whenever I switch ignore_missing_imports in the somelibrary override to true, mypy still behaves as if I had left it to false (I used this same option in the global mypy configuration to make sure to things worked the expected way, which is the case).

I'm using the (currently) latest mypy version, 0.931.

Am I doing something wrong? Is mypy bugged? Something else?

Answer

You should add your project to overrides. Lets assume your project is called "my_project" and your library/module "somelibrary" is directly under your "my_project" folder. The toml file should look like this:

[tool.mypy]
python_version = "3.7"
warn_return_any = true
warn_unused_configs = true[[tool.mypy.overrides]]
module = "my_project.somelibrary"
ignore_missing_imports = true
https://en.xdnf.cn/q/70686.html

Related Q&A

/usr/bin/env: python2.6: No such file or directory error

I have python2.6, python2.7 and python3 in my /usr/lib/I am trying to run a file which has line given below in it as its first line#!/usr/bin/env python2.6after trying to run it it gives me following e…

pandas, dataframe, groupby, std

New to pandas here. A (trivial) problem: hosts, operations, execution times. I want to group by host, then by host+operation, calculate std deviation for execution time per host, then by host+operation…

Count occurrences of a couple of specific words

I have a list of words, lets say: ["foo", "bar", "baz"] and a large string in which these words may occur. I now use for every word in the list the "string".coun…

numpy: how to fill multiple fields in a structured array at once

Very simple question: I have a structured array with multiple columns and Id like to fill only some of them (but more than one) with another preexisting array.This is what Im trying:strc = np.zeros(4, …

Combine date column and time column into datetime column

I have a Pandas dataframe like this; (obtained by parsing an excel file)| | COMPANY NAME | MEETING DATE | MEETING TIME| --------------------------------------------------------…

Matplotlib Plot Lines Above Each Bar

I would like to plot a horizontal line above each bar in this chart. The y-axis location of each bar depends on the variable target. I want to use axhline, if possible, or Line2D because I need to be …

Flask-SQLAlchemy Lower Case Index - skipping functional, not supported by SQLAlchemy reflection

First off. Apologies if this has been answered but I can not find the answer any where.I need to define a lowercase index on a Flask-SQLAlchemy object.The problem I have is I need a models username and…

pip listing global packages in active virtualenv

After upgrading pip from 1.4.x to 1.5 pip freeze outputs a list of my globally installed (system) packages instead of the ones installed inside of my virtualenv. Ive tried downgrading to 1.4 again but …

Scrapy Crawler in python cannot follow links?

I wrote a crawler in python using the scrapy tool of python. The following is the python code:from scrapy.contrib.spiders import CrawlSpider, Rule from scrapy.contrib.linkextractors.sgml import SgmlLin…

Remove commas in a string, surrounded by a comma and double quotes / Python

Ive found some similar themes on stackoverflow, but Im newbie to Python and Reg Exps.I have a string,"Completely renovated in 2009, the 2-star Superior Hotel Ibis BerlinMesse, with its 168 air-con…