wemake-services / wemake-python-styleguide

The strictest and most opinionated python linter ever!
https://wemake-python-styleguide.rtfd.io
MIT License
2.55k stars 378 forks source link

"pyflakes" failed during execution due to "'ExceptHandler' object has no attribute 'depth'" #519

Closed alextatarinov closed 5 years ago

alextatarinov commented 5 years ago

Bug report

What's wrong

flake8 fails to run pyflakes when flake-bandit version is >=2.0.0 changing flake-bandit version to 1.0.2 fixes the error. Similar error was reported earlier https://github.com/wemake-services/wemake-python-styleguide/issues/112

main.py

def test():
    try:
        x = 5
        if True:
            x = 10
    except AttributeError:
        pass

There should be if inside try block with at least one except clause. The variable shoud be defined inside try and reassigned inside if. Also using bare except removes the error.

flake8 main.py
"pyflakes" failed during execution due to "'ExceptHandler' object has no attribute 'depth'"
Run flake8 with greater verbosity to see more details

pyflakes breaks here when for some reason rnode has attrbute parent but doesn't have depth.

How is that should be

It should not raise any errors.

System information

flake8 information

{
  "dependencies": [
    {
      "dependency": "entrypoints",
      "version": "0.3"
    }
  ],
  "platform": {
    "python_implementation": "CPython",
    "python_version": "3.6.7",
    "system": "Linux"
  },
  "plugins": [
    {
      "is_local": false,
      "plugin": "flake8-annotations-complexity",
      "version": "0.0.2"
    },
    {
      "is_local": false,
      "plugin": "flake8-bandit",
      "version": "2.1.0"
    },
    {
      "is_local": false,
      "plugin": "flake8-broken-line",
      "version": "0.1.0"
    },
    {
      "is_local": false,
      "plugin": "flake8-bugbear",
      "version": "18.8.0"
    },
    {
      "is_local": false,
      "plugin": "flake8-comprehensions",
      "version": "2.1.0"
    },
    {
      "is_local": false,
      "plugin": "flake8-debugger",
      "version": "3.1.0"
    },
    {
      "is_local": false,
      "plugin": "flake8-docstrings",
      "version": "1.3.0, pydocstyle: 3.0.0"
    },
    {
      "is_local": false,
      "plugin": "flake8-eradicate",
      "version": "0.2.0"
    },
    {
      "is_local": false,
      "plugin": "flake8-print",
      "version": "3.1.0"
    },
    {
      "is_local": false,
      "plugin": "flake8-string-format",
      "version": "0.2.3"
    },
    {
      "is_local": false,
      "plugin": "flake8_builtins",
      "version": "1.4.1"
    },
    {
      "is_local": false,
      "plugin": "flake8_coding",
      "version": "1.3.1"
    },
    {
      "is_local": false,
      "plugin": "flake8_commas",
      "version": "2.0.0"
    },
    {
      "is_local": false,
      "plugin": "flake8_isort",
      "version": "2.3"
    },
    {
      "is_local": false,
      "plugin": "flake8_pep3101",
      "version": "1.2.1"
    },
    {
      "is_local": false,
      "plugin": "flake8_quotes",
      "version": "1.0.0"
    },
    {
      "is_local": false,
      "plugin": "logging-format",
      "version": "0.6.0"
    },
    {
      "is_local": false,
      "plugin": "mccabe",
      "version": "0.6.1"
    },
    {
      "is_local": false,
      "plugin": "naming",
      "version": "0.8.2"
    },
    {
      "is_local": false,
      "plugin": "pycodestyle",
      "version": "2.5.0"
    },
    {
      "is_local": false,
      "plugin": "pyflakes",
      "version": "2.1.1"
    },
    {
      "is_local": false,
      "plugin": "wemake-python-styleguide",
      "version": "0.8.0"
    }
  ],
  "version": "3.7.7"
}

For some reason I cannot reproduce this in fresh environment, trying to investigate.

pip freeze

astor==0.7.1
attrs==18.2.0
bandit==1.5.1
entrypoints==0.3
eradicate==1.0
flake8==3.7.7
flake8-annotations-complexity==0.0.2
flake8-bandit==2.1.0
flake8-broken-line==0.1.0
flake8-bugbear==18.8.0
flake8-builtins==1.4.1
flake8-coding==1.3.1
flake8-commas==2.0.0
flake8-comprehensions==2.1.0
flake8-debugger==3.1.0
flake8-docstrings==1.3.0
flake8-eradicate==0.2.0
flake8-isort==2.6.0
flake8-logging-format==0.6.0
flake8-pep3101==1.2.1
flake8-polyfill==1.0.2
flake8-print==3.1.0
flake8-quotes==1.0.0
flake8-string-format==0.2.3
gitdb2==2.0.5
GitPython==2.1.11
isort==4.3.15
mccabe==0.6.1
pbr==5.1.3
pep8-naming==0.8.2
pycodestyle==2.5.0
pydocstyle==3.0.0
pyflakes==2.1.1
PyYAML==5.1
six==1.12.0
smmap2==2.0.5
snowballstemmer==1.2.1
stevedore==1.30.1
testfixtures==6.6.1
typing==3.6.6
typing-extensions==3.7.2
wemake-python-styleguide==0.8.0
sobolevn commented 5 years ago

Thanks! Oh, this error happens quite often for some reason to other users. But it never actually happens to me. 😆

I assume that you were able to resolve it somehow, because you have created #520. Am I right?

alextatarinov commented 5 years ago

Thanks! Oh, this error happens quite often for some reason to other users. But it never actually happens to me.

I assume that you were able to resolve it somehow, because you have created #520. Am I right?

changing flake-bandit version to 1.0.2 fixes the error.

I have pinned the flake-bandit version to 1.0.2, but I am unsure about consequences. I can provide you with poetry.lock if you want, so you could try to reproduce the bug with it.

sobolevn commented 5 years ago

@tatarinov1997 yes, please. poetry.lock would be very helpful.

alextatarinov commented 5 years ago

Here you go

[tool.poetry]
name = "test"
version = "0.1.0"
description = ""
authors = ["Alexandr Tatarinov <tatarinov1997@gmail.com>"]

[tool.poetry.dependencies]
python = "^3.6"
wemake-python-styleguide = "^0.8.0"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
[[package]]
category = "main"
description = "Read/rewrite/write Python ASTs"
name = "astor"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
version = "0.7.1"

[[package]]
category = "main"
description = "Classes Without Boilerplate"
name = "attrs"
optional = false
python-versions = "*"
version = "18.2.0"

[[package]]
category = "main"
description = "Security oriented static analyser for python code."
name = "bandit"
optional = false
python-versions = "*"
version = "1.5.1"

[package.dependencies]
GitPython = ">=1.0.1"
PyYAML = ">=3.12"
six = ">=1.10.0"
stevedore = ">=1.20.0"

[[package]]
category = "main"
description = "Discover and load entry points from installed packages."
name = "entrypoints"
optional = false
python-versions = ">=2.7"
version = "0.3"

[[package]]
category = "main"
description = "Removes commented-out code."
name = "eradicate"
optional = false
python-versions = "*"
version = "1.0"

[[package]]
category = "main"
description = "the modular source code checker: pep8, pyflakes and co"
name = "flake8"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
version = "3.7.7"

[package.dependencies]
entrypoints = ">=0.3.0,<0.4.0"
mccabe = ">=0.6.0,<0.7.0"
pycodestyle = ">=2.5.0,<2.6.0"
pyflakes = ">=2.1.0,<2.2.0"

[[package]]
category = "main"
description = "A flake8 extension that checks for type annotations complexity"
name = "flake8-annotations-complexity"
optional = false
python-versions = "*"
version = "0.0.2"

[package.dependencies]
setuptools = "*"

[[package]]
category = "main"
description = "Automated security testing with bandit and flake8."
name = "flake8-bandit"
optional = false
python-versions = "*"
version = "2.1.0"

[package.dependencies]
bandit = "*"
flake8 = "*"
flake8-polyfill = "*"
pycodestyle = "*"

[[package]]
category = "main"
description = "Flake8 plugin to forbid backslashes for line breaks"
name = "flake8-broken-line"
optional = false
python-versions = ">=3.6,<4.0"
version = "0.1.0"

[package.dependencies]
flake8 = ">=3.5,<4.0"

[[package]]
category = "main"
description = "A plugin for flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle."
name = "flake8-bugbear"
optional = false
python-versions = ">=3.5"
version = "18.8.0"

[package.dependencies]
attrs = "*"
flake8 = ">=3.0.0"

[[package]]
category = "main"
description = "Check for python builtins being used as variables or parameters."
name = "flake8-builtins"
optional = false
python-versions = "*"
version = "1.4.1"

[package.dependencies]
flake8 = "*"

[[package]]
category = "main"
description = "Adds coding magic comment checks to flake8"
name = "flake8-coding"
optional = false
python-versions = "*"
version = "1.3.1"

[package.dependencies]
flake8 = "*"

[[package]]
category = "main"
description = "Flake8 lint for trailing commas."
name = "flake8-commas"
optional = false
python-versions = "*"
version = "2.0.0"

[package.dependencies]
flake8 = ">=2,<4.0.0"

[[package]]
category = "main"
description = "A flake8 plugin to help you write better list/set/dict comprehensions."
name = "flake8-comprehensions"
optional = false
python-versions = ">=3.4"
version = "2.1.0"

[package.dependencies]
flake8 = "!=3.2.0"

[[package]]
category = "main"
description = "ipdb/pdb statement checker plugin for flake8"
name = "flake8-debugger"
optional = false
python-versions = "*"
version = "3.1.0"

[package.dependencies]
flake8 = ">=1.5"
pycodestyle = "*"

[[package]]
category = "main"
description = "Extension for flake8 which uses pydocstyle to check docstrings"
name = "flake8-docstrings"
optional = false
python-versions = "*"
version = "1.3.0"

[package.dependencies]
flake8 = "*"
flake8-polyfill = "*"
pydocstyle = ">=2.1"

[[package]]
category = "main"
description = "Flake8 plugin to find commented out code"
name = "flake8-eradicate"
optional = false
python-versions = ">=3.6,<4.0"
version = "0.2.0"

[package.dependencies]
attrs = ">=18.2.0,<19.0.0"
eradicate = ">=0.2.1,<1.1.0"
flake8 = ">=3.5,<4.0"

[[package]]
category = "main"
description = "flake8 plugin that integrates isort ."
name = "flake8-isort"
optional = false
python-versions = "*"
version = "2.6.0"

[package.dependencies]
flake8 = ">=3.2.1"
isort = ">=4.3.0"
testfixtures = "*"

[[package]]
category = "main"
description = "Flake8 extension to validate (lack of) logging format strings"
name = "flake8-logging-format"
optional = false
python-versions = "*"
version = "0.6.0"

[[package]]
category = "main"
description = "Checks for old string formatting."
name = "flake8-pep3101"
optional = false
python-versions = "*"
version = "1.2.1"

[package.dependencies]
flake8 = ">=3.0"

[[package]]
category = "main"
description = "Polyfill package for Flake8 plugins"
name = "flake8-polyfill"
optional = false
python-versions = "*"
version = "1.0.2"

[package.dependencies]
flake8 = "*"

[[package]]
category = "main"
description = "print statement checker plugin for flake8"
name = "flake8-print"
optional = false
python-versions = "*"
version = "3.1.0"

[package.dependencies]
flake8 = ">=1.5"
pycodestyle = "*"
six = "*"

[[package]]
category = "main"
description = "Flake8 lint for quotes."
name = "flake8-quotes"
optional = false
python-versions = "*"
version = "1.0.0"

[package.dependencies]
flake8 = "*"

[[package]]
category = "main"
description = "string format checker, plugin for flake8"
name = "flake8-string-format"
optional = false
python-versions = "*"
version = "0.2.3"

[package.dependencies]
flake8 = "*"

[[package]]
category = "main"
description = "Git Object Database"
name = "gitdb2"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
version = "2.0.5"

[package.dependencies]
smmap2 = ">=2.0.0"

[[package]]
category = "main"
description = "Python Git Library"
name = "gitpython"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
version = "2.1.11"

[package.dependencies]
gitdb2 = ">=2.0.0"

[[package]]
category = "main"
description = "A Python utility / library to sort Python imports."
name = "isort"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
version = "4.3.15"

[[package]]
category = "main"
description = "McCabe checker, plugin for flake8"
name = "mccabe"
optional = false
python-versions = "*"
version = "0.6.1"

[[package]]
category = "main"
description = "Python Build Reasonableness"
name = "pbr"
optional = false
python-versions = "*"
version = "5.1.3"

[[package]]
category = "main"
description = "Check PEP-8 naming conventions, plugin for flake8"
name = "pep8-naming"
optional = false
python-versions = "*"
version = "0.8.2"

[package.dependencies]
flake8-polyfill = ">=1.0.2,<2"

[[package]]
category = "main"
description = "Python style guide checker"
name = "pycodestyle"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
version = "2.5.0"

[[package]]
category = "main"
description = "Python docstring style checker"
name = "pydocstyle"
optional = false
python-versions = "*"
version = "3.0.0"

[package.dependencies]
six = "*"
snowballstemmer = "*"

[[package]]
category = "main"
description = "passive checker of Python programs"
name = "pyflakes"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
version = "2.1.1"

[[package]]
category = "main"
description = "YAML parser and emitter for Python"
name = "pyyaml"
optional = false
python-versions = "*"
version = "5.1"

[[package]]
category = "main"
description = "Python 2 and 3 compatibility utilities"
name = "six"
optional = false
python-versions = ">=2.6, !=3.0.*, !=3.1.*"
version = "1.12.0"

[[package]]
category = "main"
description = "A pure Python implementation of a sliding window memory map manager"
name = "smmap2"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
version = "2.0.5"

[[package]]
category = "main"
description = "This package provides 16 stemmer algorithms (15 + Poerter English stemmer) generated from Snowball algorithms."
name = "snowballstemmer"
optional = false
python-versions = "*"
version = "1.2.1"

[[package]]
category = "main"
description = "Manage dynamic plugins for Python applications"
name = "stevedore"
optional = false
python-versions = "*"
version = "1.30.1"

[package.dependencies]
pbr = ">=2.0.0,<2.1.0 || >2.1.0"
six = ">=1.10.0"

[[package]]
category = "main"
description = "A collection of helpers and mock objects for unit tests and doc tests."
name = "testfixtures"
optional = false
python-versions = "*"
version = "6.6.1"

[[package]]
category = "main"
description = "Type Hints for Python"
name = "typing"
optional = false
python-versions = "*"
version = "3.6.6"

[[package]]
category = "main"
description = "Backported and Experimental Type Hints for Python 3.5+"
name = "typing-extensions"
optional = false
python-versions = "*"
version = "3.7.2"

[package.dependencies]
typing = ">=3.6.2"

[[package]]
category = "main"
description = "The strictest and most opinionated python linter ever"
name = "wemake-python-styleguide"
optional = false
python-versions = ">=3.6,<4.0"
version = "0.8.0"

[package.dependencies]
astor = ">=0.7.1,<0.8.0"
attrs = ">=18.2,<19.0"
flake8 = ">=3.7,<4.0"
flake8-annotations-complexity = ">=0.0.1,<0.0.3"
flake8-bandit = ">=1,<3"
flake8-broken-line = ">=0.1,<0.2"
flake8-bugbear = ">=18.2,<19.0"
flake8-builtins = ">=1.4,<2.0"
flake8-coding = ">=1.3,<2.0"
flake8-commas = ">=2.0,<3.0"
flake8-comprehensions = ">=1.4,<3.0"
flake8-debugger = ">=3.1,<4.0"
flake8-docstrings = ">=1.3,<2.0"
flake8-eradicate = ">=0.2,<0.3"
flake8-isort = ">=2.6,<3.0"
flake8-logging-format = ">=0.6,<0.7"
flake8-pep3101 = ">=1.2,<2.0"
flake8-print = ">=3.1,<4.0"
flake8-quotes = ">=1.0,<2.0"
flake8-string-format = ">=0.2,<0.3"
pep8-naming = ">=0.7,<0.9"
typing_extensions = ">=3.6,<4.0"

[metadata]
content-hash = "a2271ae98f7515a6b7f11ab39938db6b17aeec8049d7316d555b603cde3c40fe"
python-versions = "^3.6"

[metadata.hashes]
astor = ["95c30d87a6c2cf89aa628b87398466840f0ad8652f88eb173125a6df8533fb8d", "fb503b9e2fdd05609fbf557b916b4a7824171203701660f0c55bbf5a7a68713e"]
attrs = ["10cbf6e27dbce8c30807caf056c8eb50917e0eaafe86347671b57254006c3e69", "ca4be454458f9dec299268d472aaa5a11f67a4ff70093396e1ceae9c76cf4bbb"]
bandit = ["6102b5d6afd9d966df5054e0bdfc2e73a24d0fea400ec25f2e54c134412158d7", "9413facfe9de1e1bd291d525c784e1beb1a55c9916b51dae12979af63a69ba4c"]
entrypoints = ["589f874b313739ad35be6e0cd7efde2a4e9b6fea91edcc34e58ecbb8dbe56d19", "c70dd71abe5a8c85e55e12c19bd91ccfeec11a6e99044204511f9ed547d48451"]
eradicate = ["4ffda82aae6fd49dfffa777a857cb758d77502a1f2e0f54c9ac5155a39d2d01a"]
flake8 = ["859996073f341f2670741b51ec1e67a01da142831aa1fdc6242dbf88dffbe661", "a796a115208f5c03b18f332f7c11729812c8c3ded6c46319c59b53efd3819da8"]
flake8-annotations-complexity = ["e499d2186efcc5f6f2f1c7eb18568d08f4d9313fad15f614645f3f445f70b45c"]
flake8-bandit = ["5eac24fa9fef532e4e4ce599c5b3c5248c5cc435d2927537b529b0a7bcb72467", "be5840923ccf06cac6a8893a2f0abc17f03b6b9fdb5284d796f722b69c8f840b"]
flake8-broken-line = ["3eb823f48b4ec67735ebbe8e282319826c8e8be7dfc185c9e259228084c21de2", "84147d38a1562d011a8de0bb1de299a715f7dea1a7332bd6946db04a1e4c3ddd"]
flake8-bugbear = ["07b6e769d7f4e168d590f7088eae40f6ddd9fa4952bed31602def65842682c83", "0ccf56975f4db1d69dc1cf3598c99d768ebf95d0cad27d76087954aa399b515a"]
flake8-builtins = ["8d806360767947c0035feada4ddef3ede32f0a586ef457e62d811b8456ad9a51", "cd7b1b7fec4905386a3643b59f9ca8e305768da14a49a7efb31fe9364f33cd04"]
flake8-coding = ["549c2b22c08711feda11795fb49f147a626305b602c547837bab405e7981f844", "f2ee7c3c8ae47f2d278111a2090655bcf170789c24ccfea519d93be2ede7571c"]
flake8-commas = ["d3005899466f51380387df7151fb59afec666a0f4f4a2c6a8995b975de0f44b7", "ee2141a3495ef9789a3894ed8802d03eff1eaaf98ce6d8653a7c573ef101935e"]
flake8-comprehensions = ["35f826956e87f230415cde9c3b8b454e785736cf5ff0be551c441b41b937f699", "f0b61d983d608790abf3664830d68efd3412265c2d10f6a4ba1a353274dbeb64"]
flake8-debugger = ["be4fb88de3ee8f6dd5053a2d347e2c0a2b54bab6733a2280bb20ebd3c4ca1d97"]
flake8-docstrings = ["4e0ce1476b64e6291520e5570cf12b05016dd4e8ae454b8a8a9a48bc5f84e1cd", "8436396b5ecad51a122a2c99ba26e5b4e623bf6e913b0fea0cb6c2c4050f91eb"]
flake8-eradicate = ["0953cd3bcae4bfd04d45075234e0b5fd465ff50ecc56cdcaf0027da751632127", "c762fbb5c3e3694c9ba656d38477b2dcca6599b8baeee4984d05d655591a6f83"]
flake8-isort = ["3c107c405dd6e3dbdcccb2f84549d76d58a07120cd997a0560fab8b84c305f2a", "76d7dd6aec2762c608b442abebb0aaedb72fc75f9a075241a89e4784d8a39900"]
flake8-logging-format = ["ca5f2b7fc31c3474a0aa77d227e022890f641a025f0ba664418797d979a779f8"]
flake8-pep3101 = ["493821d6bdd083794eb0691ebe5b68e5c520b622b269d60e54308fb97440e21a", "b661ab718df42b87743dde266ef5de4f9e900b56c67dbccd45d24cf527545553"]
flake8-polyfill = ["12be6a34ee3ab795b19ca73505e7b55826d5f6ad7230d31b18e106400169b9e9", "e44b087597f6da52ec6393a709e7108b2905317d0c0b744cdca6208e670d8eda"]
flake8-print = ["5010e6c138b63b62400da4b06afa33becc5e08bd1fcce9af3752445cf3342f54"]
flake8-quotes = ["fd9127ad8bbcf3b546fa7871a5266fd8623ce765ebe3d5aa5eabb80c01212b26"]
flake8-string-format = ["68ea72a1a5b75e7018cae44d14f32473c798cf73d75cbaed86c6a9a907b770b2", "774d56103d9242ed968897455ef49b7d6de272000cfa83de5814273a868832f1"]
gitdb2 = ["83361131a1836661a155172932a13c08bda2db3674e4caa32368aa6eb02f38c2", "e3a0141c5f2a3f635c7209d56c496ebe1ad35da82fe4d3ec4aaa36278d70648a"]
gitpython = ["563221e5a44369c6b79172f455584c9ebbb122a13368cc82cb4b5addff788f82", "8237dc5bfd6f1366abeee5624111b9d6879393d84745a507de0fda86043b65a8"]
isort = ["18c796c2cd35eb1a1d3f012a214a542790a1aed95e29768bdcb9f2197eccbd0b", "96151fca2c6e736503981896495d344781b60d18bfda78dc11b290c6125ebdb6"]
mccabe = ["ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42", "dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"]
pbr = ["8257baf496c8522437e8a6cfe0f15e00aedc6c0e0e7c9d55eeeeab31e0853843", "8c361cc353d988e4f5b998555c88098b9d5964c2e11acf7b0d21925a66bb5824"]
pep8-naming = ["01cb1dab2f3ce9045133d08449f1b6b93531dceacb9ef04f67087c11c723cea9", "0ec891e59eea766efd3059c3d81f1da304d858220678bdc351aab73c533f2fbb"]
pycodestyle = ["95a2219d12372f05704562a14ec30bc76b05a5b297b21a5dfe3f6fac3491ae56", "e40a936c9a450ad81df37f549d676d127b1b66000a6c500caa2b085bc0ca976c"]
pydocstyle = ["2258f9b0df68b97bf3a6c29003edc5238ff8879f1efb6f1999988d934e432bd8", "5741c85e408f9e0ddf873611085e819b809fca90b619f5fd7f34bd4959da3dd4", "ed79d4ec5e92655eccc21eb0c6cf512e69512b4a97d215ace46d17e4990f2039"]
pyflakes = ["17dbeb2e3f4d772725c777fabc446d5634d1038f234e77343108ce445ea69ce0", "d976835886f8c5b31d47970ed689944a0262b5f3afa00a5a7b4dc81e5449f8a2"]
pyyaml = ["1adecc22f88d38052fb787d959f003811ca858b799590a5eaa70e63dca50308c", "436bc774ecf7c103814098159fbb84c2715d25980175292c648f2da143909f95", "460a5a4248763f6f37ea225d19d5c205677d8d525f6a83357ca622ed541830c2", "5a22a9c84653debfbf198d02fe592c176ea548cccce47553f35f466e15cf2fd4", "7a5d3f26b89d688db27822343dfa25c599627bc92093e788956372285c6298ad", "9372b04a02080752d9e6f990179a4ab840227c6e2ce15b95e1278456664cf2ba", "a5dcbebee834eaddf3fa7366316b880ff4062e4bcc9787b78c7fbb4a26ff2dd1", "aee5bab92a176e7cd034e57f46e9df9a9862a71f8f37cad167c6fc74c65f5b4e", "c51f642898c0bacd335fc119da60baae0824f2cde95b0330b56c0553439f0673", "c68ea4d3ba1705da1e0d85da6684ac657912679a649e8868bd850d2c299cce13", "e23d0cc5299223dcc37885dae624f382297717e459ea24053709675a976a3e19"]
six = ["3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c", "d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73"]
smmap2 = ["0555a7bf4df71d1ef4218e4807bbf9b201f910174e6e08af2e138d4e517b4dde", "29a9ffa0497e7f2be94ca0ed1ca1aa3cd4cf25a1f6b4f5f87f74b46ed91d609a"]
snowballstemmer = ["919f26a68b2c17a7634da993d91339e288964f93c274f1343e3bbbe2096e1128", "9f3bcd3c401c3e862ec0ebe6d2c069ebc012ce142cce209c098ccb5b09136e89"]
stevedore = ["7be098ff53d87f23d798a7ce7ae5c31f094f3deb92ba18059b1aeb1ca9fec0a0", "7d1ce610a87d26f53c087da61f06f9b7f7e552efad2a7f6d2322632b5f932ea2"]
testfixtures = ["1ff15abd7c93a25c25e707e15bc245fb3d5723e43ce114e8fd6f72cff17926c8", "30cceb538d15f17b8bf253b7f0350d5a19dd50dc55fb10902c3fc7e90d7d58ff"]
typing = ["4027c5f6127a6267a435201981ba156de91ad0d1d98e9ddc2aa173453453492d", "57dcf675a99b74d64dacf6fba08fb17cf7e3d5fdff53d4a30ea2a5e7e52543d4", "a4c8473ce11a65999c8f59cb093e70686b6c84c98df58c1dae9b3b196089858a"]
typing-extensions = ["07b2c978670896022a43c4b915df8958bec4a6b84add7f2c87b2b728bda3ba64", "f3f0e67e1d42de47b5c67c32c9b26641642e9170fe7e292991793705cd5fef7c", "fb2cd053238d33a8ec939190f30cfd736c00653a85a2919415cecf7dc3d9da71"]
wemake-python-styleguide = ["2b4350ebb7816795ce360799cc874332fa83080d6f3a1370f81e969b1cbc0566", "c5e645a08301bd8b68657d631c229de147dfb9c7cfcbd2d42bcadc334804c26b"]
sobolevn commented 5 years ago

@tatarinov1997 I have copied the provided env, and was not able to reproduce the issue.

Here's my full log:

~/Desktop/flake_bandit
» poetry install
Creating virtualenv test-py3.6 in /Users/sobolev/Desktop/flake_bandit/.venv
Installing dependencies from lock file

Package operations: 42 installs, 0 updates, 0 removals

  - Installing smmap2 (2.0.5)
  - Installing entrypoints (0.3)
  - Installing gitdb2 (2.0.5)
  - Installing mccabe (0.6.1)
  - Installing pbr (5.1.3)
  - Installing pycodestyle (2.5.0)
  - Installing pyflakes (2.1.1)
  - Installing six (1.12.0)
  - Installing flake8 (3.7.7)
  - Installing gitpython (2.1.11)
  - Installing pyyaml (5.1)
  - Installing snowballstemmer (1.2.1)
  - Installing stevedore (1.30.1)
  - Installing attrs (18.2.0)
  - Installing bandit (1.5.1)
  - Installing eradicate (1.0)
  - Installing flake8-polyfill (1.0.2)
  - Installing isort (4.3.15)
  - Installing pydocstyle (3.0.0)
  - Installing testfixtures (6.6.1)
  - Installing typing (3.6.6)
  - Installing astor (0.7.1)
  - Installing flake8-annotations-complexity (0.0.2)
  - Installing flake8-bandit (2.1.0)
  - Installing flake8-broken-line (0.1.0)
  - Installing flake8-bugbear (18.8.0)
  - Installing flake8-builtins (1.4.1)
  - Installing flake8-coding (1.3.1)
  - Installing flake8-commas (2.0.0)
  - Installing flake8-comprehensions (2.1.0)
  - Installing flake8-debugger (3.1.0)
  - Installing flake8-docstrings (1.3.0)
  - Installing flake8-eradicate (0.2.0)
  - Installing flake8-isort (2.6.0)
  - Installing flake8-logging-format (0.6.0)
  - Installing flake8-pep3101 (1.2.1)
  - Installing flake8-print (3.1.0)
  - Installing flake8-quotes (1.0.0)
  - Installing flake8-string-format (0.2.3)
  - Installing pep8-naming (0.8.2)
  - Installing typing-extensions (3.7.2)
  - Installing wemake-python-styleguide (0.8.0)
  - Installing test (0.1.0)

~/Desktop/flake_bandit
» source .venv/bin/activate

Actual run:

(.venv) ~/Desktop/flake_bandit                                                    
» flake8 test.py
test.py:0:1: C101 Coding magic comment not found
test.py:1:1: D100 Missing docstring in public module
test.py:1:1: D103 Missing docstring in public function
test.py:3:9: Z111 Found too short name: x
test.py:4:9: Z314 Conditional always evaluates to same result
test.py:5:13: Z111 Found too short name: x
test.py:5:13: F841 local variable 'x' is assigned to but never used
test.py:7:9: Z420 Found wrong keyword: pass
sobolevn commented 5 years ago

@tatarinov1997 can you please provide a reproduction repo? So I can clone it and face this issue. It would super-duper helpful! 👍

alextatarinov commented 5 years ago

@sobolevn Do you want me to include virtual environment into repo?

sobolevn commented 5 years ago

Nope, just poetry files. Virtualenv is not suited to be transported. Thanks a lot!

alextatarinov commented 5 years ago

Here you go, I have cloned it and reproduced succesfully. https://github.com/tatarinov1997/wemake-python-styleguide-519-issue

I am using Ubuntu 16.04 if this matters. Also I am using this commands

python3.6 -m venv environ
source environ/bin/activate
poetry install
flake8
sobolevn commented 5 years ago

It worked fine for me. It checked all .venv folder for violations and found millions of them.

The only difference is that I used:

poetry install
source .venv/bin/activate
flake8

I have also tried:

poetry install
poetry run flake8

My wild guess is that python3.6 -m venv environ creates broken env. To diagnose it you will need:

python3.6 -m venv environ
source environ/bin/activate
pip freeze

And I am pretty sure that you will find some packages there. Or it will discover any other packages. Try to run flake8 just after you activate your env. It might work.

So, this is not a problem with this package, but with your env. I will not close this issue for now, since I am interested in the investigation results. Please, report your status and close the issue if would fix your problem.

alextatarinov commented 5 years ago

Unfortunately, nothing new. I tried to allow poetry to create environment itself as you did (poetry install && source .venv/bin/activate), but the problem remains. I don't really want to spend our time anymore here, so I suggest closing the issue now.

sobolevn commented 5 years ago

I have faced this issue today.

» flake8 server "pyflakes" failed during execution due to "'NoneType' object has no attribute 'parent'" Run flake8 with greater verbosity to see more details

This code raises this error:

def _normalize_multiline(value: str) -> str:
    r"""
    Replaces possible multi-line values not to be multi-line.

    >>> _normalize_multiline('normal value')
    'normal value'

    >>> _normalize_multiline('multi\nline\nvalue')
    'multi line value'

    """
    return value.replace('\n', ' ')

Things that I have done:

  1. This is not our issue, because I have tried to pip uninstall wemake-python-styleguide and this error remains
  2. I have removed doctests = True and everything works just fine

I will open a bug-report to pyflakes.

asottile commented 5 years ago

I've triaged this here: https://gitlab.com/pycqa/flake8/issues/536

not sure if it's the same cause there, though it's likely

sobolevn commented 5 years ago

Pinged pyflakes about the progress.

asottile commented 5 years ago

This has been fixed in both bandit and pyflakes -- bandit has released 1.6.1 containing the fix, pyflakes has not yet released (though upgrading either solves the conflict)

sobolevn commented 5 years ago

We have bandit>=1.6.2 https://github.com/wemake-services/wemake-python-styleguide/blob/master/poetry.lock#L109

asottile commented 5 years ago

cool, should be able to close this then

sobolevn commented 5 years ago

Done. Thanks! 👍

sobolevn commented 5 years ago

I will reopen to create a regression test for this problem.

asottile commented 5 years ago

it's going to be difficult to write a test for this as it only will fail pre "ordered dicts" (py36) and 50% of the time (plugin ordering)

sobolevn commented 5 years ago

Can't reproduce.