Skip to content

pre-commit failing on flake8 hook with undefined name 'EncodingWarning' error #11356

@seanjedi

Description

@seanjedi

description of problem

On VS Code, I am attempting to commit a staged change of src_pytest\config_init_.py; however, the pre-commit hook fails on flake8 with command ouput:

flake8...................................................................Failed
- hook id: flake8
- exit code: 1

testing/_py/test_local.py:18:45: F821 undefined name 'EncodingWarning'

Every other hook either passes or is skipped. I installed pre-commit and its hook on the pytest repo using

pip list output


cachetools                    5.3.1
certifi                       2022.12.7
cffi                          1.15.1
cfgv                          3.3.1
cftime                        1.6.2
chardet                       5.2.0
charset-normalizer            2.0.4
clean                         0.1.4
clean-text                    0.6.0
cleantext                     1.1.4
click                         8.0.4
click-plugins                 1.1.1
cligj                         0.7.2
cloudpickle                   2.0.0
clyent                        1.2.2
colorama                      0.4.6
colorcet                      3.0.1
comm                          0.1.2
conda                         23.3.1
conda-build                   3.23.3
conda-content-trust           0.1.3
conda-pack                    0.6.0
conda-package-handling        2.0.2
conda_package_streaming       0.7.0
conda-repo-cli                1.0.41
conda-token                   0.4.0
conda-verify                  3.4.2
constantly                    15.1.0
contourpy                     1.0.6
cookiecutter                  1.7.3
coverage                      6.5.0
cpplint                       1.6.1
cramjam                       2.6.2
cryptography                  39.0.1
cssselect                     1.1.0
cycler                        0.11.0
Cython                        0.29.32
cytoolz                       0.12.0
daal4py                       2023.0.2
dask                          2023.3.2
datashader                    0.14.4
datashape                     0.5.4
db-dtypes                     1.0.4
debugpy                       1.5.1
decorator                     5.1.1
defusedxml                    0.7.1
diff-match-patch              20200713
dill                          0.3.6
distlib                       0.3.7
distributed                   2023.3.2
Django                        4.2.2
docstring-to-markdown         0.11
docutils                      0.18.1
doit                          0.36.0
emoji                         1.7.0
entrypoints                   0.4
et-xmlfile                    1.1.0
exceptiongroup                1.0.4
execnet                       1.9.0
executing                     1.2.0
fastjsonschema                2.16.2
fastparquet                   2022.11.0
feedparser                    6.0.10
filelock                      3.12.2
findspark                     2.0.1
Fiona                         1.8.22
firebase                      3.0.1
flake8                        6.0.0
flake8-bugbear                22.7.1
Flask                         1.1.2
flatbuffers                   23.5.26
flit_core                     3.8.0
fonttools                     4.25.0
frozenlist                    1.3.3
fsspec                        2023.3.0
ftfy                          6.1.1
future                        0.18.3
gast                          0.4.0
gcsfs                         2021.11.0
gensim                        4.3.0
geographiclib                 2.0
geopandas                     0.12.1
geopy                         2.3.0
gitdb                         4.0.9
GitPython                     3.1.29
glob2                         0.7
gmpy2                         2.1.2
google-api-core               2.10.2
google-auth                   2.14.1
google-auth-oauthlib          0.7.1
google-cloud-bigquery         3.3.6
google-cloud-bigquery-storage 2.16.2
google-cloud-core             2.3.2
google-cloud-storage          2.6.0
google-crc32c                 1.5.0
google-pasta                  0.2.0
google-resumable-media        2.4.0
googleapis-common-protos      1.57.0
greenlet                      2.0.1
grpcio                        1.50.0
grpcio-status                 1.50.0
h5py                          3.7.0
HeapDict                      1.0.1
holoviews                     1.15.4
html5lib                      1.1
huggingface-hub               0.10.1
hvplot                        0.8.2
hyperlink                     21.0.0
hypothesis                    6.58.0
identify                      2.5.8
idna                          3.4
imagecodecs                   2021.8.26
imageio                       2.26.0
imagesize                     1.4.1
imbalanced-learn              0.10.1
importlib-metadata            6.0.0
importlib-resources           5.2.0
incremental                   21.3.0
inflection                    0.5.1
iniconfig                     1.1.1
intake                        0.6.8
intervaltree                  3.1.0
ipykernel                     6.19.2
ipython                       8.12.0
ipython-genutils              0.2.0
ipywidgets                    8.0.4
isort                         5.10.1
itemadapter                   0.3.0
itemloaders                   1.0.4
itsdangerous                  2.0.1
jaraco.classes                3.2.1
jdcal                         1.4.1
jedi                          0.18.1
jeepney                       0.7.1
jellyfish                     0.9.0
Jinja2                        3.0.0
jinja2-time                   0.2.0
jmespath                      0.10.0
joblib                        1.1.1
json5                         0.9.6
jsonpatch                     1.32
jsonpointer                   2.1
jsonschema                    4.17.3
jupyter                       1.0.0
jupyter_client                7.4.9
jupyter-console               6.6.3
jupyter_core                  5.3.0
jupyter-server                1.23.4
jupyterlab                    3.5.3
jupyterlab-pygments           0.1.2
jupyterlab-server             2.10.3
jupyterlab-widgets            3.0.5
jupyterlite                   0.1.0b12
keras                         2.13.1
keyring                       23.13.1
kiwisolver                    1.4.4
lazy-object-proxy             1.6.0
libarchive-c                  2.9
libclang                      16.0.6
llvmlite                      0.39.1
locket                        1.0.0
lxml                          4.9.1
lz4                           3.1.3
Markdown                      3.4.1
MarkupSafe                    2.1.1
matplotlib                    3.7.1
matplotlib-inline             0.1.6
mccabe                        0.7.0
meteostat                     1.6.5
mistune                       2.0.4
mkl-fft                       1.3.1
mkl-random                    1.2.2
mkl-service                   2.4.0
mock                          4.0.3
more-itertools                9.0.0
moto                          4.0.10
mpmath                        1.2.1
msgpack                       1.0.3
multidict                     6.0.2
multipledispatch              0.6.0
munch                         2.5.0
munkres                       1.1.4
mypy                          0.990
mypy-extensions               0.4.3
natsort                       8.2.0
navigator-updater             0.3.0
nbclassic                     0.5.4
nbclient                      0.5.13
nbconvert                     7.2.5
nbformat                      5.7.0
nbsphinx                      0.8.10
nest-asyncio                  1.5.6
networkx                      2.8.4
nltk                          3.7
nodeenv                       1.7.0
nose                          1.3.7
notebook                      6.5.3
notebook_shim                 0.2.2
numba                         0.56.4
numexpr                       2.8.4
numpy                         1.23.5
numpydoc                      1.5.0
nvidia-cublas-cu11            11.10.3.66
nvidia-cuda-nvrtc-cu11        11.7.99
nvidia-cuda-runtime-cu11      11.7.99
nvidia-cudnn-cu11             8.5.0.96
oauthlib                      3.2.2
odfpy                         1.4.1
olefile                       0.46
openpyxl                      3.0.10
opt-einsum                    3.3.0
ortools                       9.5.2237
packaging                     23.1
pandas-datareader             0.10.0
pandas-dev-flaker             0.5.0
pandas-gbq                    0.17.9
pandoc                        2.2
pandocfilters                 1.5.0
panel                         0.14.3
param                         1.12.3
parsel                        1.6.0
parso                         0.8.3
partd                         1.2.0
pathlib                       1.0.1
pathspec                      0.10.3
patsy                         0.5.3
pep8                          1.7.1
pexpect                       4.8.0
pickleshare                   0.7.5
Pillow                        9.4.0
pip                           23.0.1
pkginfo                       1.9.6
platformdirs                  3.10.0
plotly                        5.9.0
pluggy                        1.2.0
plumbum                       1.8.0
ply                           3.11
pooch                         1.4.0
poyo                          0.5.0
pre-commit                    2.20.0
prometheus-client             0.14.1
prompt-toolkit                3.0.36
Protego                       0.1.16
proto-plus                    1.22.1
protobuf                      4.21.9
psutil                        5.9.4
psycopg2                      2.9.5
ptyprocess                    0.7.0
pure-eval                     0.2.2
py                            1.11.0
py4j                          0.10.9.5
pyarrow                       9.0.0
pyasn1                        0.4.8
pyasn1-modules                0.2.8
pycodestyle                   2.10.0
pycosat                       0.6.4
pycparser                     2.21
pyct                          0.5.0
pycurl                        7.45.2
pydata-google-auth            1.4.0
pydata-sphinx-theme           0.10.1
PyDispatcher                  2.0.5
pydocstyle                    6.3.0
pyerfa                        2.0.0
pyflakes                      3.0.1
Pygments                      2.13.0
PyHamcrest                    2.0.2
PyJWT                         2.4.0
pylint                        2.16.2
pylint-venv                   2.3.0
pyls-spyder                   0.4.0
PyMySQL                       1.0.2
pyodbc                        4.0.34
pyOpenSSL                     23.0.0
pyparsing                     3.0.9
pyproj                        3.4.0
pyproject-api                 1.5.4
PyQt5-sip                     12.11.0
pyreadstat                    1.2.0
pyrsistent                    0.18.0
PySocks                       1.7.1
pyspark                       3.3.1
pytest                        7.2.0
pytest-asyncio                0.20.2
pytest-cov                    4.0.0
pytest-cython                 0.2.0
pytest-xdist                  3.0.2
python-dateutil               2.8.2
python-lsp-black              1.2.1
python-lsp-jsonrpc            1.0.0
python-lsp-server             1.7.1
python-slugify                5.0.2
python-snappy                 0.6.1
pytoolconfig                  1.2.5
pytz                          2022.7
pyupgrade                     3.2.2
pyviz-comms                   2.0.2
PyWavelets                    1.4.1
pyxdg                         0.27
pyxlsb                        1.0.10
PyYAML                        6.0
pyzmq                         23.2.0
QDarkStyle                    3.0.2
qstylizer                     0.2.2
QtAwesome                     1.2.2
qtconsole                     5.4.0
QtPy                          2.2.0
queuelib                      1.5.0
regex                         2022.7.9
requests                      2.28.1
requests-file                 1.5.1
requests-oauthlib             1.3.1
responses                     0.22.0
rope                          1.7.0
rsa                           4.9
Rtree                         1.0.1
ruamel.yaml                   0.17.21
ruamel.yaml.clib              0.2.6
ruamel-yaml-conda             0.17.21
s3fs                          2021.11.0
s3transfer                    0.6.0
scikit-image                  0.19.3
scikit-learn                  1.2.2
scikit-learn-intelex          20230228.214108
scipy                         1.10.1
Scrapy                        2.8.0
seaborn                       0.12.2
SecretStorage                 3.3.1
Send2Trash                    1.8.0
service-identity              18.1.0
setuptools                    65.6.3
sgmllib3k                     1.0.0
Shapely                       1.8.5.post1
sip                           6.6.2
six                           1.16.0
smart-open                    5.2.1
smmap                         5.0.0
sniffio                       1.2.0
snowballstemmer               2.2.0
snscrape                      0.5.0.20230114.dev31+gf329b69
sodapy                        2.2.0
sortedcollections             2.1.0
sortedcontainers              2.4.0
soupsieve                     2.4
spark                         0.2.1
Sphinx                        5.0.2
sphinx-copybutton             0.5.1
sphinx-panels                 0.6.0
sphinx-toggleprompt           0.2.0
sphinxcontrib-applehelp       1.0.2
sphinxcontrib-devhelp         1.0.2
sphinxcontrib-htmlhelp        2.0.0
sphinxcontrib-jsmath          1.0.1
sphinxcontrib-qthelp          1.0.3
sphinxcontrib-serializinghtml 1.1.5
spyder                        5.4.2
spyder-kernels                2.4.2
SQLAlchemy                    1.4.44
sqlparse                      0.4.4
stack-data                    0.6.1
statsmodels                   0.13.5
style                         1.1.0
sympy                         1.11.1
tables                        3.7.0
tabulate                      0.9.0
TBB                           0.2
tblib                         1.7.0
tenacity                      8.0.1
tensorboard                   2.13.0
tensorboard-data-server       0.7.1
tensorflow                    2.13.0
tensorflow-estimator          2.13.0
tensorflow-io-gcs-filesystem  0.33.0
termcolor                     2.3.0
terminado                     0.17.1
testpath                      0.6.0
text-unidecode                1.3
textdistance                  4.2.1
threadpoolctl                 2.2.0
three-merge                   0.1.1
tifffile                      2021.7.2
tinycss                       0.4
tinycss2                      1.2.1
tldextract                    3.2.0
tokenize-rt                   5.0.0
tokenizers                    0.11.4
toml                          0.10.2
tomli                         2.0.1
tomlkit                       0.11.1
toolz                         0.12.0
torch                         1.13.0
tornado                       6.2
tox                           4.10.0
tqdm                          4.65.0
traitlets                     5.7.1
transformers                  4.24.0
tweepy                        4.12.1
Twisted                       22.2.0
typed-ast                     1.4.3
types-PyMySQL                 1.0.19.1
types-python-dateutil         2.8.19.4
types-pytz                    2022.6.0.1
types-setuptools              65.6.0.0
types-toml                    0.10.8.1
typing_extensions             4.4.0
tzdata                        2022.6
ujson                         5.4.0
Unidecode                     1.2.0
update                        0.0.1
urllib3                       1.26.15
versioneer                    0.28
virtualenv                    20.24.3
w3lib                         1.21.0
watchdog                      2.1.6
wcwidth                       0.2.5
webencodings                  0.5.1
websocket-client              0.58.0
Werkzeug                      2.2.2
whatthepatch                  1.0.2
wheel                         0.38.4
widgetsnbextension            4.0.5
wrapt                         1.14.1
wurlitzer                     3.0.2
xarray                        2022.11.0
xlrd                          2.0.1
XlsxWriter                    3.0.3
xmltodict                     0.13.0
yapf                          0.31.0
yarl                          1.8.1
zict                          2.1.0
zipp                          3.11.0
zope.interface                5.4.0
zstandard                     0.19.0

pytest and operating system versions

pytest --version
pytest 7.1.2
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.2 LTS
Release:        22.04
Codename:       jammy

minimal example

If I discard my changes and do pre-commit run --all-files, everything passes or is skipped except for:
Issue with mypy that can be found here: #11343
and

flake8...................................................................Failed
- hook id: flake8
- exit code: 1

testing/_py/test_local.py:18:45: F821 undefined name 'EncodingWarning'

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueeasy issue that is friendly to new contributor

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions