pylint-dev / pylint

It's not just a linter that annoys you!
https://pylint.readthedocs.io/en/latest/
GNU General Public License v2.0
5.3k stars 1.13k forks source link

Detect useless copy/deepcopy #9509

Open fc-asad opened 7 months ago

fc-asad commented 7 months ago

Current problem

I have seen code where a copy/deepcopy of an immutable data is made. As far as I understand, it is a useless operation.

Desired solution

Pylint should detect when copy/deepcopy of an immutable object is made and generate an error.

Additional context

No response

Pierre-Sassoulas commented 7 months ago

+1, but inferring if something is immutable is hard, so the check would be limited to known immutable type or the false positives would make this check unusable.