Opened 2 years ago

Closed 2 years ago

#6943 closed change (fixed)

[python-abp] Use filter.type == x instead of isinstance(filter, X) in production code

Reported by: kvas Assignee: atudor
Priority: P4 Milestone:
Module: Sitescripts Keywords: goodfirstbug
Cc: Blocked By:
Blocking: Platform: Unknown / Cross platform
Ready: yes Confidential: no
Tester: Unknown Verified working: no
Review URL(s):



The code of python-abp that works with filters mostly uses isinstance(filter, FilterClass) to match different types of filters. At the same time, all filters have .type attribute that allows distinguishing them. In fact, the main purpose of this attribute is to allow external users to write concise and simpler code and not have to import the filter classes from python-abp. We can use the same API inside of python-abp to improve clarity and speed.

What to change

Replace isinstance(filter, FilterClass) with filter.type == 'type' everywhere in production code. Introduce constants as necessary.

Change History (3)

comment:1 Changed 2 years ago by atudor

  • Owner set to atudor

comment:3 Changed 2 years ago by atudor

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.