Skip to content

Implement a check when float-only operations are used #19693

@karam-assany

Description

@karam-assany

Feature

Implement a new check that emits an error when the following conditions are met:

  1. A name is typed as builtins.float
  2. No runtime cast (the_name = float(the_name)) on that name is done
  3. A float-only attribute (like builtins.float.hex) on that name is used

This can also be extended for when the builtins.complex.__complex__ attribute (or other complex-only attributes) is used on a builtins.complex-typed name without a runtime cast.

Pitch

This document explains the whole problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions