File .deepsource.toml
not found in the default branch of the repository root. Please refer to the docs.
getattr
PTC-W0034getattr
is missing a default value126 )
127 assert len(customer_org_events) == setup_dict["num_events_in"] + 1
128 assert [
129 getattr(event, "idempotency_id") for event in customer_org_events130 ].count(setup_dict["idempotency_id"]) == 1
131
132 def test_batch_track_event_creates_event(
getattr
is missing a default value177 getattr(event, "idempotency_id") for event in customer_org_events
178 ].count(idem1) == 1
179 assert [
180 getattr(event, "idempotency_id") for event in customer_org_events181 ].count(idem2) == 1
getattr
is missing a default value174 )
175 assert len(customer_org_events) == setup_dict["num_events_in"] + 2
176 assert [
177 getattr(event, "idempotency_id") for event in customer_org_events178 ].count(idem1) == 1
179 assert [
180 getattr(event, "idempotency_id") for event in customer_org_events
getattr
is being used to check if an attribute exists, without specifying a default value.
Missing a default to getattr
will cause an AttributeError
to be raised for non-existent properties, which is the same as when a non-existent property is accessed directly.
It is recommended to either provide a default value to be returned by getattr
if the attribute is not found, or access the attribute directly as there is no additional safety in using getattr
if the attribute name is known ahead of time.