Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pre-commit AttributeError module 'enum' has no attribute 'IntFlag' macosx #56603

Closed
Ch3LL opened this issue Apr 10, 2020 · 4 comments · Fixed by #57108
Closed

pre-commit AttributeError module 'enum' has no attribute 'IntFlag' macosx #56603

Ch3LL opened this issue Apr 10, 2020 · 4 comments · Fixed by #57108
Assignees
Labels
Pending-Discussion The issue or pull request needs more discussion before it can be closed or merged ZRelease-Sodium retired label
Milestone

Comments

@Ch3LL
Copy link
Contributor

Ch3LL commented Apr 10, 2020

Description of Issue

posting stacktrace from here: #52935 (comment)

so we can add conversation in an issue

$ git commit
Linux Py2.7 ZeroMQ Requirements......................(no files to check)Skipped
Darwin Py2.7 ZeroMQ Requirements.....................(no files to check)Skipped
Windows Py2.7 ZeroMQ Requirements....................(no files to check)Skipped
Cloud Py2.7 Requirements.............................(no files to check)Skipped
Linux Py2.7 Crypto Requirements......................(no files to check)Skipped
Darwin Py2.7 Crypto Requirements.....................(no files to check)Skipped
Windows Py2.7 Crypto Requirements....................(no files to check)Skipped
Linux Py3.4 ZeroMQ Requirements......................(no files to check)Skipped
Cloud Py3.4 Requirements.............................(no files to check)Skipped
Linux Py3.4 Crypto Requirements......................(no files to check)Skipped
Linux Py3.5 ZeroMQ Requirements......................(no files to check)Skipped
Darwin Py3.5 ZeroMQ Requirements.....................(no files to check)Skipped
Windows Py3.5 ZeroMQ Requirements....................(no files to check)Skipped
Cloud Py3.5 Requirements.............................(no files to check)Skipped
Docs Py3.5 Requirements..............................(no files to check)Skipped
Linux Py3.5 Crypto Requirements......................(no files to check)Skipped
Darwin Py3.5 Crypto Requirements.....................(no files to check)Skipped
Windows Py3.5 Crypto Requirements....................(no files to check)Skipped
Lint Py3.5 Requirements..............................(no files to check)Skipped
Linux Py3.6 ZeroMQ Requirements......................(no files to check)Skipped
Darwin Py3.6 ZeroMQ Requirements.....................(no files to check)Skipped
Windows Py3.6 ZeroMQ Requirements....................(no files to check)Skipped
Cloud Py3.6 Requirements.............................(no files to check)Skipped
Docs Py3.6 Requirements..............................(no files to check)Skipped
Linux Py3.6 Crypto Requirements......................(no files to check)Skipped
Darwin Py3.6 Crypto Requirements.....................(no files to check)Skipped
Windows Py3.6 Crypto Requirements....................(no files to check)Skipped
Lint Py3.6 Requirements..............................(no files to check)Skipped
Linux Py3.7 ZeroMQ Requirements......................(no files to check)Skipped
Darwin Py3.7 ZeroMQ Requirements.....................(no files to check)Skipped
Windows Py3.7 ZeroMQ Requirements....................(no files to check)Skipped
Cloud Py3.7 Requirements.............................(no files to check)Skipped
Docs Py3.7 Requirements..............................(no files to check)Skipped
Linux Py3.7 Crypto Requirements......................(no files to check)Skipped
Darwin Py3.7 Crypto Requirements.....................(no files to check)Skipped
Windows Py3.7 Crypto Requirements....................(no files to check)Skipped
Lint Py3.7 Requirements..............................(no files to check)Skipped
isort....................................................................Passed
black....................................................................Passed
Lint Salt................................................................Failed
- hook id: nox-py2
- exit code: 1

Running session lint-salt-pre-commit
Processing pkg/osx/req.txt
Processing pkg/osx/req_ext.txt
Processing pkg/osx/req_pyobjc.txt
Processing requirements/static/darwin.in
pip install --progress-bar=off -r requirements/base.txt --constraint requirements/static/py3.7/darwin.txt --constraint requirements/static/py3.7/darwin-crypto.txt
pip install --progress-bar=off -r requirements/zeromq.txt --constraint requirements/static/py3.7/darwin.txt --constraint requirements/static/py3.7/darwin-crypto.txt
pip install --progress-bar=off -r requirements/pytest.txt --constraint requirements/static/py3.7/darwin.txt --constraint requirements/static/py3.7/darwin-crypto.txt
pip install --progress-bar=off -r pkg/osx/req.txt --constraint requirements/static/py3.7/darwin.txt --constraint requirements/static/py3.7/darwin-crypto.txt
pip install --progress-bar=off -r pkg/osx/req_ext.txt --constraint requirements/static/py3.7/darwin.txt --constraint requirements/static/py3.7/darwin-crypto.txt
pip install --progress-bar=off -r pkg/osx/req_pyobjc.txt --constraint requirements/static/py3.7/darwin.txt --constraint requirements/static/py3.7/darwin-crypto.txt
pip install --progress-bar=off -r requirements/static/darwin.in --constraint requirements/static/py3.7/darwin.txt --constraint requirements/static/py3.7/darwin-crypto.txt
pip install --progress-bar=off -r requirements/static/lint.in --constraint requirements/static/py3.7/lint.txt
Command pip install --progress-bar=off -r requirements/static/lint.in --constraint requirements/static/py3.7/lint.txt failed with exit code 1:
Collecting pylint==2.4.4 (from -c requirements/static/py3.7/lint.txt (line 13))
Downloading https://files.pythonhosted.org/packages/e9/59/43fc36c5ee316bb9aeb7cf5329cdbdca89e5749c34d5602753827c0aa2dc/pylint-2.4.4-py3-none-any.whl (302kB)
Collecting saltpylint==2019.11.14 (from -c requirements/static/py3.7/lint.txt (line 14))
Downloading https://files.pythonhosted.org/packages/fe/7f/0b5395b5d77f4d4157b327a42790179b1ec7bdfd7bd5dedbf2345b0cf6d6/SaltPyLint-2019.11.14-py2.py3-none-any.whl
Collecting mccabe==0.6.1 (from -c requirements/static/py3.7/lint.txt (line 10))
Using cached https://files.pythonhosted.org/packages/87/89/479dc97e18549e21354893e4ee4ef36db1d237534982482c3681ee6e7b57/mccabe-0.6.1-py2.py3-none-any.whl
Collecting astroid==2.3.3 (from -c requirements/static/py3.7/lint.txt (line 7))
Downloading https://files.pythonhosted.org/packages/ad/ae/86734823047962e7b8c8529186a1ac4a7ca19aaf1aa0c7713c022ef593fd/astroid-2.3.3-py3-none-any.whl (205kB)
Collecting isort==4.3.17 (from -c requirements/static/py3.7/lint.txt (line 8))
Downloading https://files.pythonhosted.org/packages/d3/57/2c79076db3c2aa9fc482628b8e70a9f6f2b4cb4b276636645b7080ac26ae/isort-4.3.17-py2.py3-none-any.whl (42kB)
Collecting modernize==0.5 (from -c requirements/static/py3.7/lint.txt (line 11))
Collecting pycodestyle==2.5.0 (from -c requirements/static/py3.7/lint.txt (line 12))
Using cached https://files.pythonhosted.org/packages/0e/0c/04a353e104d2f324f8ee5f4b32012618c1c86dd79e52a433b64fceed511b/pycodestyle-2.5.0-py2.py3-none-any.whl
Collecting lazy-object-proxy==1.4.3 (from -c requirements/static/py3.7/lint.txt (line 9))
Downloading https://files.pythonhosted.org/packages/07/3f/a3d687f83c7d44970f70ff0400677746c8860b11f0c08f6b4e07205f0cdc/lazy-object-proxy-1.4.3.tar.gz
Installing build dependencies: started
Installing build dependencies: finished with status 'error'
ERROR: Complete output from command /Users/glynn/.cache/pre-commit/repopr36g047/py_env-python3/bin/python3.7 /Users/glynn/.cache/pre-commit/repopr36g047/py_env-python3/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /private/var/folders/_9/zj6803g95zqd5zpclzp823sm0000gn/T/pip-build-env-5ne1rp_z/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=30.3.0' wheel 'setuptools_scm>=3.3.1':
ERROR: Traceback (most recent call last):
File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/glynn/.cache/pre-commit/repopr36g047/py_env-python3/lib/python3.7/site-packages/pip/__main__.py", line 16, in <module>
from pip._internal import main as _main  # isort:skip # noqa
File "/Users/glynn/.cache/pre-commit/repopr36g047/py_env-python3/lib/python3.7/site-packages/pip/_internal/__init__.py", line 4, in <module>
import locale
File "/Users/glynn/.cache/pre-commit/repopr36g047/py_env-python3/lib/python3.7/locale.py", line 16, in <module>
import re
File "/Users/glynn/.cache/pre-commit/repopr36g047/py_env-python3/lib/python3.7/re.py", line 143, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
----------------------------------------
ERROR: Command "/Users/glynn/.cache/pre-commit/repopr36g047/py_env-python3/bin/python3.7 /Users/glynn/.cache/pre-commit/repopr36g047/py_env-python3/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /private/var/folders/_9/zj6803g95zqd5zpclzp823sm0000gn/T/pip-build-env-5ne1rp_z/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=30.3.0' wheel 'setuptools_scm>=3.3.1'" failed with error code 1 in None
WARNING: You are using pip version 19.1, however version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Session lint-salt-pre-commit failed.

Lint Tests...............................................................Failed
- hook id: nox-py2
- exit code: 1

Running session lint-tests-pre-commit
Processing pkg/osx/req.txt
Processing pkg/osx/req_ext.txt
Processing pkg/osx/req_pyobjc.txt
Processing requirements/static/darwin.in
pip install --progress-bar=off -r requirements/base.txt --constraint requirements/static/py3.7/darwin.txt --constraint requirements/static/py3.7/darwin-crypto.txt
pip install --progress-bar=off -r requirements/zeromq.txt --constraint requirements/static/py3.7/darwin.txt --constraint requirements/static/py3.7/darwin-crypto.txt
pip install --progress-bar=off -r requirements/pytest.txt --constraint requirements/static/py3.7/darwin.txt --constraint requirements/static/py3.7/darwin-crypto.txt
pip install --progress-bar=off -r pkg/osx/req.txt --constraint requirements/static/py3.7/darwin.txt --constraint requirements/static/py3.7/darwin-crypto.txt
pip install --progress-bar=off -r pkg/osx/req_ext.txt --constraint requirements/static/py3.7/darwin.txt --constraint requirements/static/py3.7/darwin-crypto.txt
pip install --progress-bar=off -r pkg/osx/req_pyobjc.txt --constraint requirements/static/py3.7/darwin.txt --constraint requirements/static/py3.7/darwin-crypto.txt
pip install --progress-bar=off -r requirements/static/darwin.in --constraint requirements/static/py3.7/darwin.txt --constraint requirements/static/py3.7/darwin-crypto.txt
pip install --progress-bar=off -r requirements/static/lint.in --constraint requirements/static/py3.7/lint.txt
Command pip install --progress-bar=off -r requirements/static/lint.in --constraint requirements/static/py3.7/lint.txt failed with exit code 1:
Collecting pylint==2.4.4 (from -c requirements/static/py3.7/lint.txt (line 13))
Using cached https://files.pythonhosted.org/packages/e9/59/43fc36c5ee316bb9aeb7cf5329cdbdca89e5749c34d5602753827c0aa2dc/pylint-2.4.4-py3-none-any.whl
Collecting saltpylint==2019.11.14 (from -c requirements/static/py3.7/lint.txt (line 14))
Using cached https://files.pythonhosted.org/packages/fe/7f/0b5395b5d77f4d4157b327a42790179b1ec7bdfd7bd5dedbf2345b0cf6d6/SaltPyLint-2019.11.14-py2.py3-none-any.whl
Collecting isort==4.3.17 (from -c requirements/static/py3.7/lint.txt (line 8))
Using cached https://files.pythonhosted.org/packages/d3/57/2c79076db3c2aa9fc482628b8e70a9f6f2b4cb4b276636645b7080ac26ae/isort-4.3.17-py2.py3-none-any.whl
Collecting astroid==2.3.3 (from -c requirements/static/py3.7/lint.txt (line 7))
Using cached https://files.pythonhosted.org/packages/ad/ae/86734823047962e7b8c8529186a1ac4a7ca19aaf1aa0c7713c022ef593fd/astroid-2.3.3-py3-none-any.whl
Collecting mccabe==0.6.1 (from -c requirements/static/py3.7/lint.txt (line 10))
Using cached https://files.pythonhosted.org/packages/87/89/479dc97e18549e21354893e4ee4ef36db1d237534982482c3681ee6e7b57/mccabe-0.6.1-py2.py3-none-any.whl
Collecting modernize==0.5 (from -c requirements/static/py3.7/lint.txt (line 11))
Collecting pycodestyle==2.5.0 (from -c requirements/static/py3.7/lint.txt (line 12))
Using cached https://files.pythonhosted.org/packages/0e/0c/04a353e104d2f324f8ee5f4b32012618c1c86dd79e52a433b64fceed511b/pycodestyle-2.5.0-py2.py3-none-any.whl
Collecting lazy-object-proxy==1.4.3 (from -c requirements/static/py3.7/lint.txt (line 9))
Using cached https://files.pythonhosted.org/packages/07/3f/a3d687f83c7d44970f70ff0400677746c8860b11f0c08f6b4e07205f0cdc/lazy-object-proxy-1.4.3.tar.gz
Installing build dependencies: started
Installing build dependencies: finished with status 'error'
ERROR: Complete output from command /Users/glynn/.cache/pre-commit/repopr36g047/py_env-python3/bin/python3.7 /Users/glynn/.cache/pre-commit/repopr36g047/py_env-python3/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /private/var/folders/_9/zj6803g95zqd5zpclzp823sm0000gn/T/pip-build-env-q2zb0ap_/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=30.3.0' wheel 'setuptools_scm>=3.3.1':
ERROR: Traceback (most recent call last):
File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/glynn/.cache/pre-commit/repopr36g047/py_env-python3/lib/python3.7/site-packages/pip/__main__.py", line 16, in <module>
from pip._internal import main as _main  # isort:skip # noqa
File "/Users/glynn/.cache/pre-commit/repopr36g047/py_env-python3/lib/python3.7/site-packages/pip/_internal/__init__.py", line 4, in <module>
import locale
File "/Users/glynn/.cache/pre-commit/repopr36g047/py_env-python3/lib/python3.7/locale.py", line 16, in <module>
import re
File "/Users/glynn/.cache/pre-commit/repopr36g047/py_env-python3/lib/python3.7/re.py", line 143, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
----------------------------------------
ERROR: Command "/Users/glynn/.cache/pre-commit/repopr36g047/py_env-python3/bin/python3.7 /Users/glynn/.cache/pre-commit/repopr36g047/py_env-python3/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /private/var/folders/_9/zj6803g95zqd5zpclzp823sm0000gn/T/pip-build-env-q2zb0ap_/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=30.3.0' wheel 'setuptools_scm>=3.3.1'" failed with error code 1 in None
WARNING: You are using pip version 19.1, however version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Session lint-tests-pre-commit failed.
@Ch3LL
Copy link
Contributor Author

Ch3LL commented Apr 10, 2020

@glynnforrest this is indeed an odd error since enum is a part of the standard library and i checked the code for 3.7.4 and that attribute is there. Do you happen to have the enum34 package installed?

If you run this python -c "import enum; print(enum.__file__)" does it show the standard library location?

@Ch3LL Ch3LL added the Pending-Discussion The issue or pull request needs more discussion before it can be closed or merged label Apr 10, 2020
@Ch3LL Ch3LL added this to the Blocked milestone Apr 10, 2020
@glynnforrest
Copy link
Contributor

Thanks @Ch3LL for opening this. Here's what I did to install the pre-commit hook:

python3 -m pip install --user pre-commit
cd salt/
pre-commit install

If you run this python -c "import enum; print(enum.file)" does it show the standard library location?

$ python -c "import enum; print(enum.__file__)"
/usr/local/lib/python2.7/site-packages/enum/__init__.pyc
$ python3 -c "import enum; print(enum.__file__)"
/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/enum.py

Python 3 was installed with homebrew:

$ ls -l $(which python3)
/usr/local/bin/python3 -> ../Cellar/python/3.7.4_1/bin/python3

Installs of pip3 packages go to ~/Library/Python/3.7/lib/python/site-packages, and the executables (like pre-commit or black) go to ~/Library/Python/3.7/bin.

@Ch3LL
Copy link
Contributor Author

Ch3LL commented Apr 23, 2020

hmm it looks like its using the standard library. Do you have enum34 installed anywhere?

Not sure if you could go a step further and edit file: /Users/glynn/.cache/pre-commit/repopr36g047/py_env-python3/lib/python3.7/re.py

to print out enum.__file__ to see what its actually trying to use?

@vnitinv
Copy link
Contributor

vnitinv commented May 6, 2020

Installing enum34 cause this conflict. We should only use enum which comes default from python
Is this file bringing up enum34 https://github.com/saltstack/salt/blob/master/pkg/osx/req.txt#L8

pip install enum34
Collecting enum34
  Using cached https://files.pythonhosted.org/packages/63/f6/ccb1c83687756aeabbf3ca0f213508fcfb03883ff200d201b3a4c60cedcc/enum34-1.1.10-py3-none-any.whl
Installing collected packages: enum34
Successfully installed enum34-1.1.10
>>> enum.IntFlag
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'enum' has no attribute 'IntFlag'

step while test execution which is installing enum34

nox > pip install --progress-bar=off -r pkg/osx/req.txt --constraint requirements/static/py3.7/darwin.txt --constraint requirements/static/py3.7/darwin-crypto.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Pending-Discussion The issue or pull request needs more discussion before it can be closed or merged ZRelease-Sodium retired label
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants