Bug 403027 - type inference bloats when functools.partial is present, but functools is not imported
Summary: type inference bloats when functools.partial is present, but functools is not...
Status: CONFIRMED
Alias: None
Product: kdev-python
Classification: Developer tools
Component: Language support (show other bugs)
Version: 5.3.1
Platform: openSUSE Linux
: NOR crash
Target Milestone: ---
Assignee: Sven Brauch
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-09 10:24 UTC by myaut
Modified: 2021-01-27 16:20 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description myaut 2019-01-09 10:24:21 UTC
SUMMARY
For the following code, inferred type for bar grows exponentially each time file is reparsed (during the save, I presume), in the end this causes kdevelop to hung because it took too much to process it.

from typing import List, Optional, Tuple

class Instance:
    pass

def ham(instances: List[Instance]) -> List[Instance]:
    command_args = ["true"]
    action = functools.partial(bar, command_args=command_args)
    instances = map(action, instances)

    return list(filter(None, instances))

def bar(instance: Instance, command_args: List[str]) -> Optional[Instance]:
    return instance

Note that importing functools resolves the issue. 

OBSERVED RESULT
unsure (Instance, function unsure (Instance, function Instance (Instance, mixed)) (unsure (Instance, function Instance (Instance, mixed)), mixed)) bar( unsure (Instance, function unsure (Instance, function Instance (Instance, mixed)) (unsure (Instance, function Instance (Instance, mixed)), mixed)) instance, mixed command_args )

EXPECTED RESULT
Instance bar( Instance instance, mixed command_args)

SOFTWARE/OS VERSIONS
KDE Frameworks 5.45.0
Qt 5.9.4 (built against 5.9.4)
The xcb windowing system

ADDITIONAL INFORMATION
Comment 1 Francis Herne 2019-01-09 23:52:42 UTC
Er...right. Yes. WHAT? HOW?

Thanks for the report, I can reproduce this with 5.3-git and the provided example.

Occasionally (but not always) the type was rounded to `unsure(Instance, <callable>) bar...`, which is slightly more reasonable and prevented it from growing.
Comment 2 Justin Zobel 2021-01-12 02:03:30 UTC
Thank you for the crash report.

As it has been a while since this was reported, can you please test and confirm if this issue is still occurring or if this bug report can be marked as resolved.

I have set the bug status to "needsinfo" pending your response, please change back to "reported" or "resolved/worksforme" when you respond, thank you.
Comment 3 Bug Janitor Service 2021-01-27 04:33:22 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 4 Sven Brauch 2021-01-27 16:20:05 UTC
Setting to confirmed as I think if this was not specifically fixed, it is almost certainly still present.