untested or excessive dict comprehension

Bug #1413538 reported by hougangliu
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Identity (keystone)
Invalid
Low
Unassigned

Bug Description

in keystone/contrib/federation/utils.py
        def extract_groups(groups_by_domain):
            for groups in groups_by_domain.values():
                for group in {g['name']: g for g in groups}.values(): >>>>>>>>>>>>>> this is invalid syntax in python 2.6
                    yield group

        # initialize the group_ids as a set to eliminate duplicates
        user_name = None

Revision history for this message
Boris Bobrov (bbobrov) wrote :

Keystone doesn't support py26 any more, so it is acceptable

Changed in keystone:
status: New → Invalid
Revision history for this message
hougangliu (liuhoug) wrote :

I think "for group in {g['name']: g for g in groups}.values():" is too fancy.

why not "for group in groups:"

Changed in keystone:
status: Invalid → New
Revision history for this message
Boris Bobrov (bbobrov) wrote :

Yep, that looks weird.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to keystone (master)

Fix proposed to branch: master
Review: https://review.openstack.org/150079

Changed in keystone:
assignee: nobody → Boris Bobrov (bbobrov)
status: New → In Progress
Boris Bobrov (bbobrov)
summary: - incompatible syntax in python2.6
+ untested or excessive dict comprehension
Revision history for this message
Boris Bobrov (bbobrov) wrote :

I'm not sure if the patch above is required. There is a chance that the comprehension is there for a reason, but it seems to be untested.

Revision history for this message
Marek Denis (marek-denis) wrote :

The reason for adding this 'fancy' comprehension is that for input [{'name': 'a'}, {'name':'b'}, {'name': 'a'}] we want to remove duplicates so the output would be: ['{'name': 'a'}, {'name': 'b'}].

What tests are lacking?

Revision history for this message
Boris Bobrov (bbobrov) wrote :

> What tests are lacking?

If I remove the comprehension and leave it as 'for group in groups:' it doesn't fail tests. Thus the comprehension is not really required. Thus for nice code's sake it can be removed. Right?

If not, the comprehension removal should fail tests.

Changed in keystone:
milestone: none → kilo-rc1
Changed in keystone:
milestone: kilo-rc1 → none
importance: Undecided → Low
Revision history for this message
Dolph Mathews (dolph) wrote :

I've abandoned the referenced changed due to inactivity and failing tests. If this is still an issue, please reset the status.

Changed in keystone:
status: In Progress → Incomplete
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on keystone (master)

Change abandoned by Dolph Mathews (<email address hidden>) on branch: master
Review: https://review.openstack.org/150079
Reason: Abandoning due to inactivity and failing tests.

Revision history for this message
Morgan Fainberg (mdrnstm) wrote :

Marking as invalid since this should have expired as incomplete long ago.

Changed in keystone:
assignee: Boris Bobrov (bbobrov) → nobody
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.