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.

WPS432 should preserve the literal representation

See original GitHub issue

Bug report

This code

import pathlib

path = pathlib.Path('.')
path.chmod(0o700)

causes

WPS432: Found magic number: 448

It’s unobvious that it’s the same number and it’s impossible to use 448 in grep because it won’t find anything.

What’s wrong

Non-decimal numbers are reported as decimal. Also, maybe for things like chmod() it’s okay to allow such “magic numbers” because this form directly relates to a normal syscall or a CLI command one would make.

How is that should be

The formatting should be preserved. The error should’ve been WPS432: Found magic number: 0o700 instead.

System information

N/A

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
hhsdevcommented, Jun 29, 2020

Nice! Will wait for the PR.

0reactions
sobolevncommented, Jun 29, 2020

tl:dr; I think the implementation needs both ast and tokenizer.

Then you should probably use libcst, see #1068 I am going to merge this PR soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Source code for skfda.datasets._real_datasets - Read the Docs
Each speech frame is represented by 512 samples at a 16kHz sampling rate, ... Bunch: pass @overload def fetch_phoneme( *, return_X_y: Literal[True], ...
Read more >
PCEP:M2 - Literals Flashcards - Quizlet
Study with Quizlet and memorize flashcards containing terms like literal encode, binary numbers integers fractional floating fractional, type literal memory ...
Read more >
wemake-python-styleguide - Issuehunt
WPS432 should preserve the literal representation. Unfunded#1402created bywebknjaz. $0.00. WPS440 is wrong in compat shim modules.
Read more >
Python Data Types & Literals - Tools QA
Python Literal - Character, String and Boolean ... But in the hexadecimal number system, we have to represent the number from 10 -...
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