Merge isinstance
Documentation Index
Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt
Use this file to discover all available pages before exploring further.
Sourcery refactoring id: merge-isinstance
Section titled “Sourcery refactoring id: merge-isinstance”Description:
Section titled “Description:”Combines together multiple isinstance functions
Before:
Section titled “Before:”if isinstance(hat, Bowler) or isinstance(hat, Fedora): wear(hat)After:
Section titled “After:”if isinstance(hat, (Bowler, Fedora)): wear(hat)Explanation:
Section titled “Explanation:”When you want to check whether something is one of multiple different types, you
can merge the two isinstance checks into a single call.
This is shorter while staying nice and easy to read.