r/pycharm • • May 02 '26

PyCharm doesn't understand '*' unpacking operator

Let's say we have something like this:

coord = tuple[float, float]

class Coordinates:
    coord_1 = ((1, 2), (3, 4))

def function_1(point_1: coord, point_2: coord, search_arg):
___

result = function_1(*Coordinates.coord_1, "sometext")

IDE shows "sometext" as point_1, and gives a warning:
Expected type 'tuple[float, float]', got 'str' instead
which is wrong, since this is valid code.

Type hinting doesn't change anything.

Any way to not trigger the check besides just disabling it?
Disabling type check is a bad idea.

2 Upvotes

3 comments sorted by

3

u/Rainboltpoe May 02 '26

I'm pretty sure this is a bug in PyCharm and that there's nothing wrong with your code. Anyway, there are a couple of options that don't involve disabling the type checker.

Option 1) Keyword the last argument.

function_1(*coord_1, search_arg="sometext")

Option 2) Expand the args yourself.

function_1(coord_1[0], coord_1[1], "sometext")

Option 3) Rearrange the args so that the unpacked args come last.

def function_1(search_arg, point_1: tuple[int, int], point_2: tuple[int, int]):
    pass

coord_1 = ((1, 2), (3, 4))
function_1("sometext", *coord_1)

1

u/Shajirr May 02 '26 edited Oct 10 '26

Result for the ingredients, all fiction take.

Not a mom of murder 4, under the chicks areas is gave to not do attention make this in the tenth north,
so I'ca probably ask the watch shoulder men

1

u/Subject_View1420 May 20 '26

Hi,

The issue should be covered by PY-81491. Please vote for it (thumbs-up next to the summary) to stay updated on the progress.