update.py can't add base prefix while import style is 'import openstack.common'

Bug #1304774 reported by ChangBo Guo(gcb)
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo-incubator
Fix Released
Low
ChangBo Guo(gcb)

Bug Description

Files in module report are using 'import openstack.common.*', not 'from
openstack.common import'. In this case update.py can't replace with base name, see
https://github.com/openstack/oslo-incubator/blob/master/update.py#L163
We should add a regular expression to handle this.

Changed in oslo:
assignee: nobody → ChangBo Guo(gcb) (glongwave)
status: New → In Progress
Revision history for this message
Zhongyue Luo (zyluo) wrote :

I prefer adding a gating check to enforce "from openstack.common ... import ..."

Revision history for this message
ChangBo Guo(gcb) (glongwave) wrote :

@zyluo
As Ilya Pekelny pointed out in patchset 2.
"I see your reason. But I'll prefer avoid to dovetail imports to an inapt functionality. Because you can't guarantee that next module created right after your improvement doesn't provide "wrong" import style, because it is not wrong in fact. You should improve the `_replace` and `_copy_file` to handle all the import styles."

I think this is not hacking check , we'd better handle all the import styles.

Revision history for this message
Zhongyue Luo (zyluo) wrote :

I'm not saying from openstack.common .. import .. should be enforced by hacking. We can add this check to tox.ini for oslo only. I don't mind allowing all forms of imports but imports starting with "from" is the majority and it just seems more simple to enforcing it to avoid errors from update.py.

Revision history for this message
Openstack Gerrit (openstack-gerrit) wrote : Related fix proposed to oslo-incubator (master)

Related fix proposed to branch: master
Review: https://review.openstack.org/87832

Revision history for this message
ChangBo Guo(gcb) (glongwave) wrote :

This is gate scripts review :https://review.openstack.org/#/c/87832/

Revision history for this message
Openstack Gerrit (openstack-gerrit) wrote : Fix merged to oslo-incubator (master)

Reviewed: https://review.openstack.org/84648
Committed: https://git.openstack.org/cgit/openstack/oslo-incubator/commit/?id=145aad08a8414f64c24f68f6395472ab0b1f344f
Submitter: Jenkins
Branch: master

commit 145aad08a8414f64c24f68f6395472ab0b1f344f
Author: ChangBo Guo(gcb) <email address hidden>
Date: Wed Apr 2 15:31:24 2014 +0800

    Use from/import style in module report

    Files in module report are using 'import openstack.common.*', not 'from
    openstack.common import'. Though these two ways work well. But the first
    one let update.py can't replace with base_name, see
    https://github.com/openstack/oslo-incubator/blob/master/update.py#L163
    Considering other modules are using oslo-incubator code in the second way,
    to keep consistency, we'd better follow the last one.

    Closes-Bug: #1304774

    Change-Id: Ife98dc96b012d6aa7b5bd10d09a733506072fa1c

Changed in oslo:
status: In Progress → Fix Committed
Revision history for this message
ChangBo Guo(gcb) (glongwave) wrote :

local hacking is in review https://review.openstack.org/#/c/87832/

Changed in oslo:
importance: Undecided → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Reviewed: https://review.openstack.org/87832
Committed: https://git.openstack.org/cgit/openstack/oslo-incubator/commit/?id=b9edac561941a5312ecbdeaff518e3828746feb9
Submitter: Jenkins
Branch: master

commit b9edac561941a5312ecbdeaff518e3828746feb9
Author: ChangBo Guo(gcb) <email address hidden>
Date: Wed May 21 17:04:11 2014 +0800

    Fix update.py can't replace base name

    update.py scans 'from openstack.common.*' to replace base name while
    syncing, there is another import style 'import openstack.common.*'.
    This patch handles this case.

    Closes-Bug: #1304774
    Change-Id: I29caef5faff2ec7b2eebd5c61bcf39f91e6e9265

Thierry Carrez (ttx)
Changed in oslo:
milestone: none → juno-1
status: Fix Committed → Fix Released
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.