Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[format check] Misleading scientific, engineering, or underscore grouping notations infloat#10425

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
Pierre-Sassoulas wants to merge15 commits intopylint-dev:main
base:main
Choose a base branch
Loading
fromPierre-Sassoulas:scientific-notation-formatting

Conversation

Pierre-Sassoulas
Copy link
Member

@Pierre-SassoulasPierre-Sassoulas commentedJun 12, 2025
edited
Loading

Type of Changes

Type
✨ New feature

Description

A little experiment to gather feedback with primers and reviews (still a draft).

The idea is to enforce normalized ways to write number above a threshold or close to 0 in absolute value:

  • Engineering notation (float)
  • Scientific notation (float)
  • Pep515 notation with underscore separated by pack of 3 digit (float or int)

Another idea could be to warn to use python's Decimal for number with more than 15 digits of precision, not sure if it should be the same checker though. We could also set/enforce a default precision for a project.

SomeFrenchGuy and mbyrnepr2 reacted with thumbs up emoji
@Pierre-SassoulasPierre-Sassoulas added this to the4.0.0 milestoneJun 12, 2025
@Pierre-SassoulasPierre-Sassoulas added the Enhancement ✨Improvement to a component labelJun 12, 2025
Comment on lines +463 to +529
if string.endswith("l"):
self.add_message("lowercase-l-suffix", line=line_num)
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Never raised anywhere, the definition of the message cannot be found, not sure what it's about.

@codecovCodecov
Copy link

codecovbot commentedJun 12, 2025
edited
Loading

Codecov Report

Attention: Patch coverage is97.35450% with5 lines in your changes missing coverage. Please review.

Project coverage is 95.90%. Comparing base(f5aa766) to head(dc7592d).

Files with missing linesPatch %Lines
pylint/checkers/format.py97.35%5 Missing⚠️

❌ Your patch check has failed because the patch coverage (97.35%) is below the target coverage (100.00%). You can increase the patch coverage or adjust thetarget coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@##             main   #10425      +/-   ##==========================================+ Coverage   95.88%   95.90%   +0.01%==========================================  Files         176      176                Lines       19140    19325     +185     ==========================================+ Hits        18352    18533     +181- Misses        788      792       +4
Files with missing linesCoverage Δ
pylint/checkers/format.py97.08% <97.35%> (+0.47%)⬆️
🚀 New features to boost your workflow:
  • ❄️Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Pierre-SassoulasPierre-Sassoulasforce-pushed thescientific-notation-formatting branch fromfdf5bc1 to18b00a7CompareJune 13, 2025 19:11
@Pierre-SassoulasPierre-Sassoulas changed the title[format] Add a check for standard scientific notation[format check] Misleading scientific notations and use of underscore grouping infloatJun 13, 2025
@Pierre-SassoulasPierre-Sassoulas marked this pull request as draftJune 14, 2025 18:53
Copy link
Collaborator

@DanielNoordDanielNoord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Seems useful, but would probably make it an extension? Or perhaps, first have it as an extension to get feedback?

@mbyrnepr2
Copy link
Member

+1 for the idea

@Pierre-SassoulasPierre-Sassoulas changed the title[format check] Misleading scientific notations and use of underscore grouping infloat[format check] Misleading scientific, engineering or underscore grouping notations infloatJun 17, 2025
@Pierre-SassoulasPierre-Sassoulas changed the title[format check] Misleading scientific, engineering or underscore grouping notations infloat[format check] Misleading scientific, engineering, or underscore grouping notations infloatJun 17, 2025
@Pierre-SassoulasPierre-Sassoulasforce-pushed thescientific-notation-formatting branch fromf3ff9d4 to1db9508CompareJune 17, 2025 21:35
Comment on lines 515 to 524
"x" not in string # not a hexadecimal
and "o" not in string # not an octal
and "j" not in string # not a complex
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

PEP 515 is talking about separating word in hexadecimal, might want to do something about it... later.

@Pierre-SassoulasPierre-Sassoulasforce-pushed thescientific-notation-formatting branch from1db9508 to77a3d6bCompareJune 18, 2025 12:29
@github-actionsGitHub Actions

This comment has been minimized.

@Pierre-SassoulasPierre-Sassoulasforce-pushed thescientific-notation-formatting branch fromcbe8b6a to2886dc7CompareJune 21, 2025 09:12
@github-actionsGitHub Actions

This comment has been minimized.

@github-actionsGitHub Actions

This comment has been minimized.

@github-actionsGitHub Actions

This comment has been minimized.

@github-actionsGitHub Actions

This comment has been minimized.

@Pierre-SassoulasPierre-Sassoulasforce-pushed thescientific-notation-formatting branch from8ba51e0 to35898deCompareJune 21, 2025 19:41
@github-actionsGitHub Actions

This comment has been minimized.

@github-actionsGitHub Actions

This comment has been minimized.

@github-actionsGitHub Actions

This comment has been minimized.

@github-actionsGitHub Actions

This comment has been minimized.

@Pierre-SassoulasPierre-Sassoulasforce-pushed thescientific-notation-formatting branch fromafc04e3 todc7592dCompareJune 22, 2025 20:57
@github-actionsGitHub Actions
Copy link
Contributor

🤖Effect of this PR on checked open source code: 🤖

Effect onhome-assistant:
The following messages are now emitted:

  1. bad-float-notation:
    '1000000.0' is bigger than 1e6, and it should be written as '1_000_000.0' or '1e6' instead
    https://github.com/home-assistant/core/blob/7442f7af28d28a2f6e5417f4cb45e08476be63ac/homeassistant/components/esphome/light.py#L244
  2. bad-float-notation:
    '6356752.314245' is bigger than 1e6, and it should be written as '6.356752314245e6' or '6_356_752.314245' instead
    https://github.com/home-assistant/core/blob/7442f7af28d28a2f6e5417f4cb45e08476be63ac/homeassistant/util/location.py#L26

Effect onsentry:
The following messages are now emitted:

  1. bad-float-notation:
    '1541455200.0' is bigger than 1e6, and it should be written as '(3600 * 24 * 365 * 48) + (320 * 3600 * 24) + (22 * 3600)' or '1.5414552e9' or '1_541_455_200.0' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/issue_examples.py#L53
  2. bad-float-notation:
    '1541458800.0' is bigger than 1e6, and it should be written as '(3600 * 24 * 365 * 48) + (320 * 3600 * 24) + (23 * 3600)' or '1.5414588e9' or '1_541_458_800.0' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/issue_examples.py#L54
  3. bad-float-notation:
    '1541462400.0' is bigger than 1e6, and it should be written as '(3600 * 24 * 365 * 48) + (321 * 3600 * 24)' or '1.5414624e9' or '1_541_462_400.0' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/issue_examples.py#L55
  4. bad-float-notation:
    '1541466000.0' is bigger than 1e6, and it should be written as '(3600 * 24 * 365 * 48) + (321 * 3600 * 24) + (1 * 3600)' or '1.541466e9' or '1_541_466_000.0' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/issue_examples.py#L56
  5. bad-float-notation:
    '1541469600.0' is bigger than 1e6, and it should be written as '(3600 * 24 * 365 * 48) + (321 * 3600 * 24) + (2 * 3600)' or '1.5414696e9' or '1_541_469_600.0' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/issue_examples.py#L57
  6. bad-float-notation:
    '1541473200.0' is bigger than 1e6, and it should be written as '(3600 * 24 * 365 * 48) + (321 * 3600 * 24) + (3 * 3600)' or '1.5414732e9' or '1_541_473_200.0' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/issue_examples.py#L58
  7. bad-float-notation:
    '1541476800.0' is bigger than 1e6, and it should be written as '(3600 * 24 * 365 * 48) + (321 * 3600 * 24) + (4 * 3600)' or '1.5414768e9' or '1_541_476_800.0' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/issue_examples.py#L59
  8. bad-float-notation:
    '1541480400.0' is bigger than 1e6, and it should be written as '(3600 * 24 * 365 * 48) + (321 * 3600 * 24) + (5 * 3600)' or '1.5414804e9' or '1_541_480_400.0' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/issue_examples.py#L60
  9. bad-float-notation:
    '1541484000.0' is bigger than 1e6, and it should be written as '(3600 * 24 * 365 * 48) + (321 * 3600 * 24) + (6 * 3600)' or '1.541484e9' or '1_541_484_000.0' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/issue_examples.py#L61
  10. bad-float-notation:
    '1541487600.0' is bigger than 1e6, and it should be written as '(3600 * 24 * 365 * 48) + (321 * 3600 * 24) + (7 * 3600)' or '1.5414876e9' or '1_541_487_600.0' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/issue_examples.py#L62
  11. bad-float-notation:
    '1541491200.0' is bigger than 1e6, and it should be written as '(3600 * 24 * 365 * 48) + (321 * 3600 * 24) + (8 * 3600)' or '1.5414912e9' or '1_541_491_200.0' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/issue_examples.py#L63
  12. bad-float-notation:
    '1541494800.0' is bigger than 1e6, and it should be written as '(3600 * 24 * 365 * 48) + (321 * 3600 * 24) + (9 * 3600)' or '1.5414948e9' or '1_541_494_800.0' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/issue_examples.py#L64
  13. bad-float-notation:
    '1541498400.0' is bigger than 1e6, and it should be written as '(3600 * 24 * 365 * 48) + (321 * 3600 * 24) + (10 * 3600)' or '1.5414984e9' or '1_541_498_400.0' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/issue_examples.py#L65
  14. bad-float-notation:
    '1541502000.0' is bigger than 1e6, and it should be written as '(3600 * 24 * 365 * 48) + (321 * 3600 * 24) + (11 * 3600)' or '1.541502e9' or '1_541_502_000.0' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/issue_examples.py#L66
  15. bad-float-notation:
    '1541505600.0' is bigger than 1e6, and it should be written as '(3600 * 24 * 365 * 48) + (321 * 3600 * 24) + (12 * 3600)' or '1.5415056e9' or '1_541_505_600.0' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/issue_examples.py#L67
  16. bad-float-notation:
    '1541509200.0' is bigger than 1e6, and it should be written as '(3600 * 24 * 365 * 48) + (321 * 3600 * 24) + (13 * 3600)' or '1.5415092e9' or '1_541_509_200.0' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/issue_examples.py#L68
  17. bad-float-notation:
    '1541512800.0' is bigger than 1e6, and it should be written as '(3600 * 24 * 365 * 48) + (321 * 3600 * 24) + (14 * 3600)' or '1.5415128e9' or '1_541_512_800.0' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/issue_examples.py#L69
  18. bad-float-notation:
    '1541516400.0' is bigger than 1e6, and it should be written as '(3600 * 24 * 365 * 48) + (321 * 3600 * 24) + (15 * 3600)' or '1.5415164e9' or '1_541_516_400.0' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/issue_examples.py#L70
  19. bad-float-notation:
    '1541520000.0' is bigger than 1e6, and it should be written as '(3600 * 24 * 365 * 48) + (321 * 3600 * 24) + (16 * 3600)' or '1.54152e9' or '1_541_520_000.0' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/issue_examples.py#L71
  20. bad-float-notation:
    '1541523600.0' is bigger than 1e6, and it should be written as '(3600 * 24 * 365 * 48) + (321 * 3600 * 24) + (17 * 3600)' or '1.5415236e9' or '1_541_523_600.0' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/issue_examples.py#L72
  21. bad-float-notation:
    '1541527200.0' is bigger than 1e6, and it should be written as '(3600 * 24 * 365 * 48) + (321 * 3600 * 24) + (18 * 3600)' or '1.5415272e9' or '1_541_527_200.0' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/issue_examples.py#L73
  22. bad-float-notation:
    '1541530800.0' is bigger than 1e6, and it should be written as '(3600 * 24 * 365 * 48) + (321 * 3600 * 24) + (19 * 3600)' or '1.5415308e9' or '1_541_530_800.0' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/issue_examples.py#L74
  23. bad-float-notation:
    '1541534400.0' is bigger than 1e6, and it should be written as '(3600 * 24 * 365 * 48) + (321 * 3600 * 24) + (20 * 3600)' or '1.5415344e9' or '1_541_534_400.0' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/issue_examples.py#L75
  24. bad-float-notation:
    '1541538000.0' is bigger than 1e6, and it should be written as '(3600 * 24 * 365 * 48) + (321 * 3600 * 24) + (21 * 3600)' or '1.541538e9' or '1_541_538_000.0' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/issue_examples.py#L76
  25. bad-float-notation:
    '1658770772.902' is bigger than 1e6, and it should be written as '1.658770772902e9' or '1_658_770_772.902' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/replay_examples.py#L123
  26. bad-float-notation:
    '1658770772.902' is bigger than 1e6, and it should be written as '1.658770772902e9' or '1_658_770_772.902' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/replay_examples.py#L129
  27. bad-float-notation:
    '1658770772.902' is bigger than 1e6, and it should be written as '1.658770772902e9' or '1_658_770_772.902' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/replay_examples.py#L130
  28. bad-float-notation:
    '1665063926.125' is bigger than 1e6, and it should be written as '1.665063926125e9' or '1_665_063_926.125' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/replay_examples.py#L145
  29. bad-float-notation:
    '1665063926.125' is bigger than 1e6, and it should be written as '1.665063926125e9' or '1_665_063_926.125' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/replay_examples.py#L151
  30. bad-float-notation:
    '1665063926.833' is bigger than 1e6, and it should be written as '1.665063926833e9' or '1_665_063_926.833' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/replay_examples.py#L152
  31. bad-float-notation:
    '1658770772.902' is bigger than 1e6, and it should be written as '1.658770772902e9' or '1_658_770_772.902' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/replay_examples.py#L170
  32. bad-float-notation:
    '1658770772.902' is bigger than 1e6, and it should be written as '1.658770772902e9' or '1_658_770_772.902' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/replay_examples.py#L176
  33. bad-float-notation:
    '1658770772.902' is bigger than 1e6, and it should be written as '1.658770772902e9' or '1_658_770_772.902' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/apidocs/examples/replay_examples.py#L177
  34. bad-float-notation:
    '172422171096.56' is bigger than 1e6, and it should be written as '1.7242217109656e11' or '172.42217109656e9' or '172_422_171_096.56' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/testutils/helpers/notifications.py#L289
  35. bad-float-notation:
    '1504656000.0' is bigger than 1e6, and it should be written as '(3600 * 24 * 365 * 47) + (260 * 3600 * 24)' or '1.504656e9' or '1_504_656_000.0' instead
    https://github.com/getsentry/sentry/blob/0da785052b486eb791022727af5805a291d059a4/src/sentry/web/frontend/debug/mail.py#L198

This comment was generated for commitdc7592d

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@DanielNoordDanielNoordDanielNoord left review comments

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
Enhancement ✨Improvement to a component
Projects
None yet
Milestone
4.0.0
Development

Successfully merging this pull request may close these issues.

3 participants
@Pierre-Sassoulas@mbyrnepr2@DanielNoord

[8]ページ先頭

©2009-2025 Movatter.jp