Opened on 09/11/2018 at 01:21:10 PM

Closed on 09/24/2018 at 10:39:13 AM

#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):

Description

Background

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.

Attachments (0)

Change History (3)

comment:1 Changed on 09/24/2018 at 10:06:00 AM by atudor

  • Owner set to atudor

comment:2 Changed on 09/24/2018 at 10:39:02 AM by atudor

comment:3 Changed on 09/24/2018 at 10:39:13 AM by atudor

  • Resolution set to fixed
  • Status changed from new to closed

Add Comment

Modify Ticket

Change Properties
Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from atudor.
 
Note: See TracTickets for help on using tickets.