Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple false positives for numeric NewTypes #6696

Closed
theCapypara opened this issue May 25, 2022 · 1 comment
Closed

Multiple false positives for numeric NewTypes #6696

theCapypara opened this issue May 25, 2022 · 1 comment
Labels
Duplicate 🐫 Duplicate of an already existing issue

Comments

@theCapypara
Copy link

theCapypara commented May 25, 2022

Bug description

Using a NewType that is an integer and performing an unary operation will incorrectly show the invalid-unary-operand-type error.
Trying to use it to index an array will report invalid-sequence-index.
Trying to call a method of int on an int NewType will report no-member.

I haven't tested it, but the same would probably apply at floats.

In the example below, i32 is defined as:

T = TypeVar('T')


@dataclass
class ValueRange(Generic[T]):
    min: T
    max: T


i32 = NewType('i32', Annotated[int, ValueRange(-2_147_483_648, 2_147_483_647)])

Configuration

No response

Command used

pylint package_name

Pylint output

************* Module skytemple_files.graphics.kao._writer
skytemple_files/graphics/kao/_writer.py:77:43: E1130: bad operand type for unary -: i32 (invalid-unary-operand-type)
skytemple_files/graphics/kao/_writer.py:90:31: E1130: bad operand type for unary -: i32 (invalid-unary-operand-type)
************* Module skytemple_files.patch.handler.expand_poke_list
skytemple_files/patch/handler/expand_poke_list.py:232:16: E1126: Sequence index is not an int, slice, or instance with __index__ (invalid-sequence-index)
skytemple_files/patch/handler/expand_poke_list.py:239:16: E1126: Sequence index is not an int, slice, or instance with __index__ (invalid-sequence-index)
skytemple_files/patch/handler/expand_poke_list.py:246:16: E1126: Sequence index is not an int, slice, or instance with __index__ (invalid-sequence-index)
skytemple_files/patch/handler/expand_poke_list.py:247:16: E1126: Sequence index is not an int, slice, or instance with __index__ (invalid-sequence-index)
************* Module skytemple_files.compression_container._prviate.bma_collision_rle._pymodel
skytemple_files/compression_container/_prviate/bma_collision_rle/_pymodel.py:40:17: E1101: Instance of 'u16' has no 'to_bytes' member (no-member)

Expected behavior

I would expect no error to be reported.

Pylint version

pylint 2.13.9
astroid 2.11.5
Python 3.10.4 (main, Mar 23 2022, 23:05:40) [GCC 11.2.0]

OS / Environment

No response

Additional dependencies

No response

@theCapypara theCapypara added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label May 25, 2022
@theCapypara theCapypara changed the title Multiple false positives for numeric NewType's Multiple false positives for numeric NewTypes May 25, 2022
@jacobtylerwalls
Copy link
Member

Duplicate of #2296 and #3162. Please reopen if you are able to determine that pylint-dev/astroid#1301 will not resolve your issues. We appreciate everyone who helps test pylint/astroid dev!

@jacobtylerwalls jacobtylerwalls closed this as not planned Won't fix, can't repro, duplicate, stale May 25, 2022
@jacobtylerwalls jacobtylerwalls added Duplicate 🐫 Duplicate of an already existing issue and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate 🐫 Duplicate of an already existing issue
Projects
None yet
Development

No branches or pull requests

2 participants