question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Magic number is found even though it was assigned to a variable

See original GitHub issue

Bug report

Using the sample code from the help page:

price_in_euro = 3.33  # could be changed later
total = get_items_from_cart() * price_in_euro

Returns Z432 as error code

Same for any other piece of code like this:

foo = 19091
do(foo)

What’s wrong

Returns Z432 as error code

How is that should be

This piece of code should not raise Z432 because the number was assigned to a variable.

System information

flake8 information

Contents of flake8 --bug-report:

PS C:\Python36\Scripts> C:\Temp\SampleEnv\Scripts\flake8.exe --bug-report
{
  "dependencies": [
    {
      "dependency": "setuptools",
      "version": "39.0.1"
    }
  ],
  "platform": {
    "python_implementation": "CPython",
    "python_version": "3.6.6",
    "system": "Windows"
  },
  "plugins": [
    {
      "is_local": false,
      "plugin": "flake8-bandit",
      "version": "v1.0.2"
    },
    {
      "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": "1.4.1"
    },
    {
      "is_local": false,
      "plugin": "flake8-debugger",
      "version": "3.1.0"
    },
    {
      "is_local": false,
      "plugin": "flake8-docstrings",
      "version": "1.3.0, pydocstyle: 2.1.1"
    },
    {
      "is_local": false,
      "plugin": "flake8-eradicate",
      "version": "0.1.1"
    },
    {
      "is_local": false,
      "plugin": "flake8-string-format",
      "version": "0.2.3"
    },
    {
      "is_local": false,
      "plugin": "flake8-type-annotations",
      "version": "0.1.0"
    },
    {
      "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.5.0"
    },
    {
      "is_local": false,
      "plugin": "mccabe",
      "version": "0.6.1"
    },
    {
      "is_local": false,
      "plugin": "naming",
      "version": "0.7.0"
    },
    {
      "is_local": false,
      "plugin": "pycodestyle",
      "version": "2.3.1"
    },
    {
      "is_local": false,
      "plugin": "pyflakes",
      "version": "1.6.0"
    },
    {
      "is_local": false,
      "plugin": "wemake-python-styleguide",
      "version": "0.2.0"
    }
  ],
  "version": "3.5.0"
}

pip information

Contents of pip freeze:

PS C:\Python36\Scripts> pip freeze
autopep8==1.4
CacheControl==0.12.5
cachy==0.2.0
certifi==2018.8.24
chardet==3.0.4
cleo==0.6.8
html5lib==1.0.1
idna==2.7
jsonschema==2.6.0
lockfile==0.12.2
msgpack==0.5.6
pastel==0.1.0
pkginfo==1.4.2
poetry==0.11.5
pycodestyle==2.4.0
pylev==1.3.0
pyparsing==2.2.2
pyrsistent==0.14.4
requests==2.19.1
requests-toolbelt==0.8.0
shellingham==1.2.6
six==1.11.0
tomlkit==0.4.4
urllib3==1.23
webencodings==0.5.1
yapf==0.24.0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
AlexArcPycommented, Oct 16, 2018

I’ve tried various things but this seems to be specific to my Windows 10 environment. Since if I understood it right the appveyor tests on Windows pass, this issue could be closed and no further action is required in this regard.

1reaction
AlexArcPycommented, Oct 13, 2018

Sure, will try to dig to see if I find anything. Yes, I am able to see this error raised on Windows 10 machine with the latest linter installed. Will post here if I find anything worth sharing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is a magic number, and why is it bad? - Stack Overflow
First, magic numbers are not just numbers. Any basic value can be "magic". Basic values are manifest entities such as integers, reals, doubles,...
Read more >
When is two a magic number? - JavaScript Code Readability
A magic number is a number that appears directly in source code, but should really be given a name and used as a...
Read more >
Is every number in the code considered a "magic number"?
A magic number is the computer science equivalent of in-band signaling. It means there is a number in a domain (say, integers) that...
Read more >
Magic number (programming) - Wikipedia
In computer programming, a magic number is any of the following: A unique value with unexplained meaning or multiple occurrences which could (preferably)...
Read more >
Find nth Magic Number - GeeksforGeeks
If we notice carefully the magic numbers can be represented as 001, 010, 011, 100, 101, 110 etc, where 001 is 0*pow(5,3) +...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found