Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM7183: Port to Python 3 #2

Merged
merged 11 commits into from Sep 20, 2016
Merged

DM7183: Port to Python 3 #2

merged 11 commits into from Sep 20, 2016

Conversation

timj
Copy link
Member

@timj timj commented Sep 15, 2016

No description provided.

@timj
Copy link
Member Author

timj commented Sep 15, 2016

Two quick observations:

  1. .decode() is probably better than .decode("utf-8") as our default encoding is going to be fine (and we are mostly ASCII anyhow).
  2. There are a few assertTrues that should be assertIn, assertFalse or assertIsInstance.

srp3rd and others added 7 commits September 19, 2016 13:17
Squashed commits:
[448ae0b] Fixing warnings from flake8
Squashed commits:
[b173929] more flake8 cleanup
…llowed in

python 3

converted command line output reading from bin to utf-8

Fixed ShareData references
Fixing api docs

flake8 cleanup

Ran futurize -2 -x division_safe -n -w .
Copy link
Member Author

@timj timj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very similar comments to those I made in lsst/ctrl_execute#2 -- lots of if False that I don't think are needed. Asserts need modernizing.

Also, the review system killed the performance of Safari...

@@ -66,26 +73,26 @@ def _extract(self, field, repos, policy, pipelinePolicySet):
if policy.getValueType(field) == pol.Policy.FILE:
filename = policy.getFile(field).getPath()
filename = os.path.join(repos, filename)
if (filename in self.policySet) == False:
if (filename in self.policySet) is False:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if filename not in self.policySet:

?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in DM-7183

self.policySet.add(filename)
if (filename in pipelinePolicySet) == False:
if (filename in pipelinePolicySet) is False:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use not in and drop the is False?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in DM-7183

if bFirst == True:
item = list[0]
while os.path.exists(item) == False:
if bFirst is True:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if bFirst is a boolean type then we don't need the is True.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in DM-7183

while os.path.exists(item) == False:
if bFirst is True:
item = fileList[0]
while os.path.exists(item) is False:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while not os.path.exists(item):

?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in DM-7183

newlist = [ item for item in list if (os.path.exists(item) == False)]
list = newlist
while len(fileList) > 0:
newlist = [item for item2 in fileList if (os.path.exists(item) is False)]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... if not os.path.exists(item)]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-wrote this loop in DM-7639

self.sd.release()
self.assert_(not self.sd._is_owned(), "lock not released")
self.assertTrue(not self.sd._is_owned(), "lock not released")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertFalse

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in DM-7639

@@ -157,59 +158,60 @@ def testNoLockRead(self):
try:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with self.assertRaises

for key in "name test config".split():
self.assert_(key in attrs, "Missing attr: " + key)
self.assertTrue(key in attrs, "Missing attr: " + key)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertIn

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in DM-7639

self.assert_(isinstance(self.sd.test, bool))
self.assert_(self.sd.test)
self.assertEqual(self.sd.name, "Ray")
self.assertTrue(isinstance(self.sd.test, bool))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertIsInstance

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in DM-7639

protected = self.sd.config
self.assert_(isinstance(protected, dict))
self.assertEquals(len(protected), 0)
self.assertTrue(isinstance(protected, dict))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertIsInstance

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in DM-7639

fix list(keys()) redundancy is SharedData
newlist = [ item for item in list if (os.path.exists(item) == False)]
list = newlist
while len(fileList) > 0:
newlist = [item for item2 in fileList if (os.path.exists(item) is False)]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why this item is changed to item2?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent catch. It would seem this should be

newlist = [item for item in fileList if not os.path.exists(item)]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in DM-7639; rewrote this loop.

def dir(self):
return filter(lambda k: k != "__", self._d.keys())

return list([k for k in self._d if k != "__"])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this list() needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. The [...] is already a list.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in DM-7639

@srp3rd srp3rd merged commit 7e3e33d into master Sep 20, 2016
@timj
Copy link
Member Author

timj commented Sep 20, 2016

@srp3rd I'm not sure what happened here because this branch really needed to be rebased and there's a weird "merge from master" in the history. Also, you did not address the item2 issue above, or @hchiang2's other comment on list() usage. You also didn't say why you decided against modernizing the tests.

@srp3rd
Copy link
Contributor

srp3rd commented Sep 21, 2016

This was merge was an error because I when I looked for the pull on Monday, I didn't see it, and merge on Tuesday when I saw the message in jira that code had been reviewed. In between marking it for review and this pull, I made additional changes to the "is True", "is False", and list(keys()) code (which is why I marked them here as fixed in DM-7183).

@ktlim ktlim deleted the tickets/DM-7183 branch August 25, 2018 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants