Repository: dask/distributed

Issue:
Mypy - distributed/scheduler.py:120: error: disable_error_code: Invalid error code(s): annotation-unchecked 
<!-- Please include a self-contained copy-pastable example that generates the issue if possible.

Please be concise with code posted. See guidelines below on how to provide a good bug report:

- Craft Minimal Bug Reports http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports
- Minimal Complete Verifiable Examples https://stackoverflow.com/help/mcve

Bug reports that follow these guidelines are easier to diagnose, and so are often handled much more quickly.
-->

**Describe the issue**:

The xarray CI has just started getting the following mypy error, see https://github.com/pydata/xarray/pull/7204 as an example:
```
 Collecting types-cryptography
  Downloading types_cryptography-3.3.23.2-py3-none-any.whl (30 kB)
Installing collected packages: types-setuptools, types-PyYAML, types-pytz, types-cryptography, types-paramiko
Successfully installed types-PyYAML-6.0.12.2 types-cryptography-3.3.23.2 types-paramiko-2.12.0.1 types-pytz-2022.6.0.1 types-setuptools-65.6.0.2
/home/runner/micromamba-root/envs/xarray-tests/lib/python3.8/site-packages/distributed/scheduler.py:120: error: disable_error_code: Invalid error code(s): annotation-unchecked  [misc]
Generated Cobertura report: /home/runner/work/xarray/xarray/mypy_report/cobertura.xml
Installing missing stub packages:
/home/runner/micromamba-root/envs/xarray-tests/bin/python -m pip install types-PyYAML types-paramiko types-pytz types-setuptools


Generated Cobertura report: /home/runner/work/xarray/xarray/mypy_report/cobertura.xml
Found 1 error in 1 file (checked 140 source files)
```

**Anything else we need to know?**:

**Environment**:

<details> 

```
# packages in environment at /home/runner/micromamba-root/envs/xarray-tests:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       2_gnu    conda-forge
affine                    2.3.1              pyhd8ed1ab_0    conda-forge
aiobotocore               2.4.0              pyhd8ed1ab_0    conda-forge
aiohttp                   3.8.3            py38h0a891b7_1    conda-forge
aioitertools              0.11.0             pyhd8ed1ab_0    conda-forge
aiosignal                 1.3.1              pyhd8ed1ab_0    conda-forge
antlr-python-runtime      4.7.2           py38h578d9bd_1003    conda-forge
appdirs                   1.4.4              pyh9f0ad1d_0    conda-forge
asciitree                 0.3.3                      py_2    conda-forge
async-timeout             4.0.2              pyhd8ed1ab_0    conda-forge
attrs                     22.1.0             pyh71513ae_1    conda-forge
backports                 1.0                pyhd8ed1ab_3    conda-forge
backports.zoneinfo        0.2.1            py38h0a891b7_7    conda-forge
beautifulsoup4            4.11.1             pyha770c72_0    conda-forge
blosc                     1.21.1               h83bc5f7_3    conda-forge
boost-cpp                 1.78.0               h75c5d50_1    conda-forge
boto3                     1.24.59            pyhd8ed1ab_0    conda-forge
botocore                  1.27.59            pyhd8ed1ab_0    conda-forge
bottleneck                1.3.5            py38h26c90d9_1    conda-forge
brotli                    1.0.9                h166bdaf_8    conda-forge
brotli-bin                1.0.9                h166bdaf_8    conda-forge
brotlipy                  0.7.0           py38h0a891b7_1005    conda-forge
bzip2                     1.0.8                h7f98852_4    conda-forge
c-ares                    1.18.1               h7f98852_0    conda-forge
ca-certificates           2022.9.24            ha878542_0    conda-forge
cached-property           1.5.2                hd8ed1ab_1    conda-forge
cached_property           1.5.2              pyha770c72_1    conda-forge
cairo                     1.16.0            ha61ee94_1014    conda-forge
cartopy                   0.21.0           py38hf6c3373_3    conda-forge
cdat_info                 8.2.1              pyhd8ed1ab_2    conda-forge
cdms2                     3.1.5           py38hc1ef740_14    conda-forge
cdtime                    3.1.4            py38hc54c017_7    conda-forge
certifi                   2022.9.24          pyhd8ed1ab_0    conda-forge
cf-units                  3.1.1            py38h26c90d9_2    conda-forge
cffi                      1.15.1           py38h4a40e3a_2    conda-forge
cfgrib                    0.9.10.3           pyhd8ed1ab_0    conda-forge
cfgv                      3.3.1              pyhd8ed1ab_0    conda-forge
cfitsio                   4.2.0                hd9d235c_0    conda-forge
cftime                    1.6.2            py38h26c90d9_1    conda-forge
charset-normalizer        2.1.1              pyhd8ed1ab_0    conda-forge
click                     8.1.3           unix_pyhd8ed1ab_2    conda-forge
click-plugins             1.1.1                      py_0    conda-forge
cligj                     0.7.2              pyhd8ed1ab_1    conda-forge
cloudpickle               2.2.0              pyhd8ed1ab_0    conda-forge
colorama                  0.4.6              pyhd8ed1ab_0    conda-forge
conda                     22.9.0           py38h578d9bd_2    conda-forge
conda-package-handling    2.0.2              pyh38be061_0    conda-forge
conda-package-streaming   0.7.0              pyhd8ed1ab_1    conda-forge
contourpy                 1.0.6            py38h43d8883_0    conda-forge
coverage                  6.5.0            py38h0a891b7_1    conda-forge
cryptography              38.0.4           py38h80a4ca7_0    conda-forge
curl                      7.86.0               h2283fc2_1    conda-forge
cycler                    0.11.0             pyhd8ed1ab_0    conda-forge
cytoolz                   0.12.0           py38h0a891b7_1    conda-forge
dask-core                 2022.12.0          pyhd8ed1ab_0    conda-forge
distarray                 2.12.2             pyhd8ed1ab_2    conda-forge
distlib                   0.3.6              pyhd8ed1ab_0    conda-forge
distributed               2022.12.0          pyhd8ed1ab_0    conda-forge
docopt                    0.6.2                      py_1    conda-forge
eccodes                   2.27.1               h7f7619e_0    conda-forge
entrypoints               0.4                pyhd8ed1ab_0    conda-forge
esmf                      8.2.0           nompi_h1ee4d8d_2    conda-forge
esmpy                     8.2.0           nompi_py38h6633fd3_1    conda-forge
exceptiongroup            1.0.4              pyhd8ed1ab_0    conda-forge
execnet                   1.9.0              pyhd8ed1ab_0    conda-forge
expat                     2.5.0                h27087fc_0    conda-forge
fasteners                 0.17.3             pyhd8ed1ab_0    conda-forge
filelock                  3.8.2              pyhd8ed1ab_0    conda-forge
findlibs                  0.0.2              pyhd8ed1ab_0    conda-forge
flox                      0.6.5              pyhd8ed1ab_0    conda-forge
font-ttf-dejavu-sans-mono 2.37                 hab24e00_0    conda-forge
font-ttf-inconsolata      3.000                h77eed37_0    conda-forge
font-ttf-source-code-pro  2.038                h77eed37_0    conda-forge
font-ttf-ubuntu           0.83                 hab24e00_0    conda-forge
fontconfig                2.14.1               hc2a2eb6_0    conda-forge
fonts-conda-ecosystem     1                             0    conda-forge
fonts-conda-forge         1                             0    conda-forge
fonttools                 4.38.0           py38h0a891b7_1    conda-forge
freeglut                  3.2.2                h9c3ff4c_1    conda-forge
freetype                  2.12.1               hca18f0e_1    conda-forge
freexl                    1.0.6                h166bdaf_1    conda-forge
frozenlist                1.3.3            py38h0a891b7_0    conda-forge
fsspec                    2022.11.0          pyhd8ed1ab_0    conda-forge
future                    0.18.2             pyhd8ed1ab_6    conda-forge
g2clib                    1.6.3                hbecde78_1    conda-forge
geos                      3.11.1               h27087fc_0    conda-forge
geotiff                   1.7.1                ha76d385_4    conda-forge
gettext                   0.21.1               h27087fc_0    conda-forge
giflib                    5.2.1                h36c2ea0_2    conda-forge
h5netcdf                  1.1.0              pyhd8ed1ab_0    conda-forge
h5py                      3.7.0           nompi_py38h7927eab_102    conda-forge
hdf4                      4.2.15               h9772cbc_5    conda-forge
hdf5                      1.12.2          nompi_h4df4325_100    conda-forge
heapdict                  1.0.1                      py_0    conda-forge
hypothesis                6.60.0             pyha770c72_0    conda-forge
icu                       70.1                 h27087fc_0    conda-forge
identify                  2.5.9              pyhd8ed1ab_0    conda-forge
idna                      3.4                pyhd8ed1ab_0    conda-forge
importlib-metadata        5.1.0              pyha770c72_0    conda-forge
importlib_resources       5.10.1             pyhd8ed1ab_0    conda-forge
iniconfig                 1.1.1              pyh9f0ad1d_0    conda-forge
iris                      3.4.0              pyhd8ed1ab_0    conda-forge
jasper                    2.0.33               ha77e612_0    conda-forge
jinja2                    3.1.2              pyhd8ed1ab_1    conda-forge
jmespath                  1.0.1              pyhd8ed1ab_0    conda-forge
jpeg                      9e                   h166bdaf_2    conda-forge
json-c                    0.16                 hc379101_0    conda-forge
jsonschema                4.17.3             pyhd8ed1ab_0    conda-forge
jupyter_core              5.1.0            py38h578d9bd_0    conda-forge
kealib                    1.5.0                ha7026e8_0    conda-forge
keyutils                  1.6.1                h166bdaf_0    conda-forge
kiwisolver                1.4.4            py38h43d8883_1    conda-forge
krb5                      1.19.3               h08a2579_0    conda-forge
lazy-object-proxy         1.8.0            py38h0a891b7_0    conda-forge
lcms2                     2.14                 h6ed2654_0    conda-forge
ld_impl_linux-64          2.39                 hcc3a1bd_1    conda-forge
lerc                      4.0.0                h27087fc_0    conda-forge
libaec                    1.0.6                h9c3ff4c_0    conda-forge
libblas                   3.9.0           16_linux64_openblas    conda-forge
libbrotlicommon           1.0.9                h166bdaf_8    conda-forge
libbrotlidec              1.0.9                h166bdaf_8    conda-forge
libbrotlienc              1.0.9                h166bdaf_8    conda-forge
libcblas                  3.9.0           16_linux64_openblas    conda-forge
libcdms                   3.1.2              h2973bc7_118    conda-forge
libcf                     1.0.3           py38h0c3d773_115    conda-forge
libcurl                   7.86.0               h2283fc2_1    conda-forge
libdeflate                1.14                 h166bdaf_0    conda-forge
libdrs                    3.1.2              hf593df3_118    conda-forge
libdrs_f                  3.1.2              h7e76ec7_114    conda-forge
libedit                   3.1.20191231         he28a2e2_2    conda-forge
libev                     4.33                 h516909a_1    conda-forge
libffi                    3.4.2                h7f98852_5    conda-forge
libgcc-ng                 12.2.0              h65d4601_19    conda-forge
libgdal                   3.6.0               hedffb84_11    conda-forge
libgfortran-ng            12.2.0              h69a702a_19    conda-forge
libgfortran5              12.2.0              h337968e_19    conda-forge
libglib                   2.74.1               h606061b_1    conda-forge
libglu                    9.0.0             he1b5a44_1001    conda-forge
libgomp                   12.2.0              h65d4601_19    conda-forge
libiconv                  1.17                 h166bdaf_0    conda-forge
libkml                    1.3.0             h37653c0_1015    conda-forge
liblapack                 3.9.0           16_linux64_openblas    conda-forge
libllvm11                 11.1.0               he0ac6c6_5    conda-forge
libnetcdf                 4.8.1           nompi_h261ec11_106    conda-forge
libnghttp2                1.47.0               hff17c54_1    conda-forge
libnsl                    2.0.0                h7f98852_0    conda-forge
libopenblas               0.3.21          pthreads_h78a6416_3    conda-forge
libpng                    1.6.39               h753d276_0    conda-forge
libpq                     15.1                 h67c24c5_1    conda-forge
librttopo                 1.1.0               ha49c73b_12    conda-forge
libspatialite             5.0.1               h7c8129e_22    conda-forge
libsqlite                 3.40.0               h753d276_0    conda-forge
libssh2                   1.10.0               hf14f497_3    conda-forge
libstdcxx-ng              12.2.0              h46fd767_19    conda-forge
libtiff                   4.4.0                h55922b4_4    conda-forge
libuuid                   2.32.1            h7f98852_1000    conda-forge
libwebp-base              1.2.4                h166bdaf_0    conda-forge
libxcb                    1.13              h7f98852_1004    conda-forge
libxml2                   2.10.3               h7463322_0    conda-forge
libxslt                   1.1.37               h873f0b0_0    conda-forge
libzip                    1.9.2                hc929e4a_1    conda-forge
libzlib                   1.2.13               h166bdaf_4    conda-forge
llvmlite                  0.39.1           py38h38d86a4_1    conda-forge
locket                    1.0.0              pyhd8ed1ab_0    conda-forge
lxml                      4.9.1            py38ha9ef780_1    conda-forge
lz4-c                     1.9.3                h9c3ff4c_1    conda-forge
markupsafe                2.1.1            py38h0a891b7_2    conda-forge
matplotlib-base           3.6.2            py38hb021067_0    conda-forge
msgpack-python            1.0.4            py38h43d8883_1    conda-forge
multidict                 6.0.2            py38h0a891b7_2    conda-forge
munkres                   1.1.4              pyh9f0ad1d_0    conda-forge
mypy                      0.982                    pypi_0    pypi
mypy-extensions           0.4.3                    pypi_0    pypi
nbformat                  5.7.0              pyhd8ed1ab_0    conda-forge
nc-time-axis              1.4.1              pyhd8ed1ab_0    conda-forge
ncurses                   6.3                  h27087fc_1    conda-forge
netcdf-fortran            4.6.0           nompi_hc402ea5_101    conda-forge
netcdf4                   1.6.0           nompi_py38h6b4b75c_103    conda-forge
nodeenv                   1.7.0              pyhd8ed1ab_0    conda-forge
nomkl                     1.0                  h5ca1d4c_0    conda-forge
nspr                      4.35                 h27087fc_0    conda-forge
nss                       3.82                 he02c5a1_0    conda-forge
numba                     0.56.4           py38h9a4aae9_0    conda-forge
numbagg                   0.2.1                    pypi_0    pypi
numcodecs                 0.10.2           py38hfa26641_0    conda-forge
numexpr                   2.8.3           py38h36ff5c2_101    conda-forge
numpy                     1.23.5           py38h7042d01_0    conda-forge
numpy_groupies            0.9.20             pyhd8ed1ab_0    conda-forge
openblas                  0.3.21          pthreads_h320a7e8_3    conda-forge
openjpeg                  2.5.0                h7d73246_1    conda-forge
openssl                   3.0.7                h0b41bf4_1    conda-forge
packaging                 21.3               pyhd8ed1ab_0    conda-forge
pandas                    1.5.2            py38h8f669ce_0    conda-forge
partd                     1.3.0              pyhd8ed1ab_0    conda-forge
patsy                     0.5.3              pyhd8ed1ab_0    conda-forge
pcre2                     10.40                hc3806b6_0    conda-forge
pillow                    9.2.0            py38h9eb91d8_3    conda-forge
pint                      0.20.1             pyhd8ed1ab_0    conda-forge
pip                       22.3.1             pyhd8ed1ab_0    conda-forge
pixman                    0.40.0               h36c2ea0_0    conda-forge
pkgutil-resolve-name      1.3.10             pyhd8ed1ab_0    conda-forge
platformdirs              2.5.2              pyhd8ed1ab_1    conda-forge
pluggy                    1.0.0              pyhd8ed1ab_5    conda-forge
pooch                     1.6.0              pyhd8ed1ab_0    conda-forge
poppler                   22.11.0              h92391eb_0    conda-forge
poppler-data              0.4.11               hd8ed1ab_0    conda-forge
postgresql                15.1                 ha105346_1    conda-forge
pre-commit                2.20.0           py38h578d9bd_1    conda-forge
proj                      9.1.0                h93bde94_0    conda-forge
pseudonetcdf              3.2.2              pyhd8ed1ab_0    conda-forge
psutil                    5.9.4            py38h0a891b7_0    conda-forge
pthread-stubs             0.4               h36c2ea0_1001    conda-forge
pycosat                   0.6.4            py38h0a891b7_1    conda-forge
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pydap                     3.3.0              pyhd8ed1ab_0    conda-forge
pyopenssl                 22.1.0             pyhd8ed1ab_0    conda-forge
pyparsing                 3.0.9              pyhd8ed1ab_0    conda-forge
pyproj                    3.4.0            py38hce0a2d1_2    conda-forge
pyrsistent                0.19.2           py38h0a891b7_0    conda-forge
pyshp                     2.3.1              pyhd8ed1ab_0    conda-forge
pysocks                   1.7.1              pyha2e5f31_6    conda-forge
pytest                    7.2.0              pyhd8ed1ab_2    conda-forge
pytest-cov                4.0.0              pyhd8ed1ab_0    conda-forge
pytest-env                0.6.2                      py_0    conda-forge
pytest-xdist              3.1.0              pyhd8ed1ab_0    conda-forge
python                    3.8.15          h4a9ceb5_0_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python-eccodes            1.4.2            py38h26c90d9_1    conda-forge
python-fastjsonschema     2.16.2             pyhd8ed1ab_0    conda-forge
python-xxhash             3.0.0            py38h0a891b7_2    conda-forge
python_abi                3.8                      3_cp38    conda-forge
pytz                      2022.6             pyhd8ed1ab_0    conda-forge
pyyaml                    6.0              py38h0a891b7_5    conda-forge
qhull                     2020.2               h4bd325d_2    conda-forge
rasterio                  1.3.4            py38h485b76c_0    conda-forge
readline                  8.1.2                h0f457ee_0    conda-forge
requests                  2.28.1             pyhd8ed1ab_1    conda-forge
ruamel_yaml               0.15.80         py38h0a891b7_1008    conda-forge
s3transfer                0.6.0              pyhd8ed1ab_0    conda-forge
scipy                     1.9.3            py38h8ce737c_2    conda-forge
seaborn                   0.12.1               hd8ed1ab_0    conda-forge
seaborn-base              0.12.1             pyhd8ed1ab_0    conda-forge
setuptools                65.5.1             pyhd8ed1ab_0    conda-forge
shapely                   1.8.5            py38hafd38ec_2    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
snappy                    1.1.9                hbd366e4_2    conda-forge
snuggs                    1.4.7                      py_0    conda-forge
sortedcontainers          2.4.0              pyhd8ed1ab_0    conda-forge
soupsieve                 2.3.2.post1        pyhd8ed1ab_0    conda-forge
sparse                    0.13.0             pyhd8ed1ab_0    conda-forge
sqlite                    3.40.0               h4ff8645_0    conda-forge
statsmodels               0.13.5           py38h26c90d9_2    conda-forge
tblib                     1.7.0              pyhd8ed1ab_0    conda-forge
tiledb                    2.11.3               h3f4058f_1    conda-forge
tk                        8.6.12               h27826a3_0    conda-forge
toml                      0.10.2             pyhd8ed1ab_0    conda-forge
tomli                     2.0.1              pyhd8ed1ab_0    conda-forge
toolz                     0.12.0             pyhd8ed1ab_0    conda-forge
tornado                   6.2              py38h0a891b7_1    conda-forge
traitlets                 5.6.0              pyhd8ed1ab_0    conda-forge
typing-extensions         4.4.0                hd8ed1ab_0    conda-forge
typing_extensions         4.4.0              pyha770c72_0    conda-forge
tzcode                    2022g                h166bdaf_0    conda-forge
tzdata                    2022g                h191b570_0    conda-forge
udunits2                  2.2.28               hc3e0081_0    conda-forge
ukkonen                   1.0.1            py38h43d8883_3    conda-forge
unicodedata2              15.0.0           py38h0a891b7_0    conda-forge
urllib3                   1.26.13            pyhd8ed1ab_0    conda-forge
virtualenv                20.17.0          py38h578d9bd_0    conda-forge
webob                     1.8.7              pyhd8ed1ab_0    conda-forge
wheel                     0.38.4             pyhd8ed1ab_0    conda-forge
wrapt                     1.14.1           py38h0a891b7_1    conda-forge
xarray                    2022.12.1.dev14+g96ae79da          pypi_0    pypi
xerces-c                  3.2.4                h55805fa_1    conda-forge
xorg-fixesproto           5.0               h7f98852_1002    conda-forge
xorg-inputproto           2.3.2             h7f98852_1002    conda-forge
xorg-kbproto              1.0.7             h7f98852_1002    conda-forge
xorg-libice               1.0.10               h7f98852_0    conda-forge
xorg-libsm                1.2.3             hd9c2040_1000    conda-forge
xorg-libx11               1.7.2                h7f98852_0    conda-forge
xorg-libxau               1.0.9                h7f98852_0    conda-forge
xorg-libxdmcp             1.1.3                h7f98852_0    conda-forge
xorg-libxext              1.3.4                h7f98852_1    conda-forge
xorg-libxfixes            5.0.3             h7f98852_1004    conda-forge
xorg-libxi                1.7.10               h7f98852_0    conda-forge
xorg-libxrender           0.9.10            h7f98852_1003    conda-forge
xorg-renderproto          0.11.1            h7f98852_1002    conda-forge
xorg-xextproto            7.3.0             h7f98852_1002    conda-forge
xorg-xproto               7.0.31            h7f98852_1007    conda-forge
xxhash                    0.8.0                h7f98852_3    conda-forge
xz                        5.2.6                h166bdaf_0    conda-forge
yaml                      0.2.5                h7f98852_2    conda-forge
yarl                      1.8.1            py38h0a891b7_0    conda-forge
zarr                      2.13.3             pyhd8ed1ab_0    conda-forge
zict                      2.2.0              pyhd8ed1ab_0    conda-forge
zipp                      3.11.0             pyhd8ed1ab_0    conda-forge
zlib                      1.2.13               h166bdaf_4    conda-forge
zstandard                 0.19.0           py38h5945529_1    conda-forge
zstd                      1.5.2                h6239696_4    conda-forge
/home/runner/micromamba-root/envs/xarray-tests/lib/python3.8/site-packages/_distutils_hack/__init__.py:33: UserWarning: Setuptools is replacing distutils.
```

</details>


Discussion:
Thanks for reporting @Illviljan. cc @crusaderky due to the type annotation and xarray-connection. 

Quickly skimming the `git blame`, it looks like https://github.com/dask/distributed/pull/7349 is where `disable-error-code` was added 

Resolving patch:
diff --git a/distributed/scheduler.py b/distributed/scheduler.py
--- a/distributed/scheduler.py
+++ b/distributed/scheduler.py
@@ -116,9 +116,6 @@
 from distributed.utils_perf import disable_gc_diagnosis, enable_gc_diagnosis
 from distributed.variable import VariableExtension
 
-# FIXME improve annotations. See also special treatment in setup.cfg.
-# mypy: disable-error-code=annotation-unchecked
-
 if TYPE_CHECKING:
     # TODO import from typing (requires Python >=3.10)
     from typing_extensions import TypeAlias


Test patch: