If you want to have some guidelines to improve and optimize your code, try Refurb.
Refurb is only available for Python 3.10 and above.
Link to Refurb.