Skip to content

Replace type() by isinstance() #2636

@sebix

Description

@sebix

All the type(a) is b and similar need to be replaced by isinstance(a, b).

Occurences that I found (automatically and manually):

intelmq/bin/intelmqdump.py:        if type(value['traceback']) is not list:
intelmq/bin/intelmqdump.py:                    if type(value['traceback']) is not list:
intelmq/bin/intelmqctl.py:            if type(log_message) is not dict:
intelmq/bin/intelmqctl.py:                if type(retval) is str:
intelmq/bin/intelmqctl.py:                        if type(retval) is str:
intelmq/bots/experts/filter/expert.py:                if type(self.not_after) is datetime and event_time > self.not_after:
intelmq/bots/experts/filter/expert.py:                if type(self.not_before) is datetime and event_time < self.not_before:
intelmq/bots/experts/filter/expert.py:                if type(self.not_after) is timedelta and event_time > (now - self.not_after):
intelmq/bots/experts/filter/expert.py:                if type(self.not_before) is timedelta and event_time < (now - self.not_before):
intelmq/bots/experts/format_field/expert.py:        if type(self.strip_columns) is str:
intelmq/bots/experts/rdap/expert.py:            if type(self.rdap_bootstrapped_servers[service]) is str:
intelmq/bots/experts/rdap/expert.py:            elif type(self.rdap_bootstrapped_servers) is dict:
intelmq/bots/experts/rdap/expert.py:            if type(vcardentry) is str:
intelmq/bots/parsers/generic/parser_csv.py:        if type(self.columns) is str:
intelmq/bots/parsers/html_table/parser.py:        if type(self.columns) is str:
intelmq/bots/parsers/html_table/parser.py:        if type(self.ignore_values) is str:
intelmq/lib/harmonization.py:        if type(value) is not str:
intelmq/lib/bot.py:        queues_type = type(self.destination_queues)
intelmq/lib/bot.py:        if queues_type is dict:
intelmq/lib/bot.py:                elif type(value) is list or isinstance(value, types.GeneratorType):
intelmq/lib/pipeline.py:            type_ = type(queues)
intelmq/lib/pipeline.py:            if type_ is list:
intelmq/lib/pipeline.py:            elif type_ is str:
intelmq/lib/test.py:        if type(cls.default_input_message) is dict:
intelmq/lib/test.py:                if type(msg) is dict:
intelmq/lib/test.py:                elif issubclass(type(msg), message.Message):
intelmq/lib/upgrades.py:                if type(config) is dict:
intelmq/lib/upgrades.py:            if type(columns) is str:
intelmq/lib/utils.py:    return (item for sublist in (queues.values() if type(queues) is dict else queues) for item in
intelmq/lib/utils.py:            (sublist if type(sublist) is list else [sublist]))
intelmq/lib/utils.py:        if type(syslog) is tuple or type(syslog) is list:
intelmq/lib/utils.py:    return traceback.format_exception_only(type(exc), exc)[-1].strip().replace(type(exc).__name__ + ': ', '')
intelmq/lib/message.py:        if dict_eq and issubclass(type(other), Message):
intelmq/lib/message.py:            type_eq = type(self) is type(other)
intelmq/tests/lib/test_message.py:        self.assertEqual(type(report),
intelmq/tests/lib/test_message.py:        self.assertEqual(type(event),
intelmq/tests/lib/test_message.py:        event_type = type(message.MessageFactory.from_dict(event,

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: coregood first issueIndicates a good issue for first-time contributorshelp wantedIndicates that a maintainer wants help on an issue or pull request

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions