[codeface] Re: [PATCH 2/9] Fix unresolvable variable in cluster.py computeProximityLinks

  • From: Wolfgang Mauerer <wolfgang.mauerer@xxxxxxxxxxxxxxxxx>
  • To: <codeface@xxxxxxxxxxxxx>, "Joblin, Mitchell (ext)" <mitchell.joblin.ext@xxxxxxxxxxx>, Andreas Ringlstetter <andreas.ringlstetter@xxxxxxxxxxxxxxxxxxxx>
  • Date: Wed, 16 Sep 2015 21:13:29 +0200

Am 16/09/2015 um 19:35 schrieb Andreas Ringlstetter:

Am 16.09.2015 um 15:01 schrieb Wolfgang Mauerer:
Am 15/09/2015 um 03:43 schrieb Andreas Ringlstetter:
From: Andreas Ringlstetter <andreas.ringlstetter@xxxxxxxxx>

Signed-off-by: Andreas Ringlstetter <andreas.ringlstetter@xxxxxxxxx>
---
codeface/cluster/cluster.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/codeface/cluster/cluster.py b/codeface/cluster/cluster.py
index f443090..d363ff3 100755
--- a/codeface/cluster/cluster.py
+++ b/codeface/cluster/cluster.py
@@ -1533,10 +1533,10 @@ def computeProximityLinks(fileCommitList, cmtList,
id_mgr, link_type, \
Collaboration is quantified by a single metric indicating the
strength of collaboration between two individuals.
'''
- for file_commit in fileCommitList.values():
+ for fileCommit in fileCommitList.values():

if speedUp:
- computeSnapshotCollaboration(file_commit, cmtList, id_mgr,
link_type,
+ computeSnapshotCollaboration(fileCommit, cmtList, id_mgr,
link_type,
startDate)

why change only file_commit to fileCommit, but leave everything
else (id_mgr, link_type, ...) as is? Besides, most of the code uses
underscores for variable names, so why switch to camel case in this
particular case?

I didn't switch the names. The camel case name was there first and is
used in the rest of the function. Only this single reference to the
variable used underscore and wasn't resolvable, so it would have
resulted in a runtime error. That is if the function wasn't currently
uncovered by any possible code path or test.
that's unfortunately not visible from the hunk. Please document this
in the commit message. The patch is fine then.

I did not intend to perform any refactoring related to PEP0008
violations in this set yet. Only removal or fixup of code which is
impossible to recover in the next iteration.

In general, we should move to a more explicit style guide, for instance
google's:
https://google-styleguide.googlecode.com/svn/trunk/pyguide.html.
Currently, we're just referring to python.org, which
would mean pep0008, but the document does not specify a preferred
way of naming variables as far as I'm aware of. The google guide
does. Thoughts on this, anyone?

Even PEP0008 specifies a naming scheme for variables, functions and classes:
https://www.python.org/dev/peps/pep-0008/#naming-conventions

that lists all possibilities, but I cannot see where they set one
_specific_ consistent scheme. Let's go for the google style guide.

It isn't as specific as Google's style guide, but it would have been
nice if it had been followed throughout Codeface's history.
Research project. People are usually more interested in writing
the next paper than caring for code consistency. I'll link to the google
guide on the homepage.

As far as naming convention goes, there is only one differences between
PEP0008 and Google style:
PEP discourages the use of underscores in package names, while Google
recommends it. Doesn't matter as long as package names are only single
words.

Apart from that, I don't see any incompatibilties between PEP8 and
Google style. They are mostly identical in fact, only a few cases where
the Google style is slightly stricter.

Personally I would recommend linking to Google's Python style as it is
well written and also covers some code smell which PEP8 does not.
Especially when it comes to "How to use Exceptions properly", "How not
to break pickling" and "Why you shouldn't write smart generator
expressions".

At least the first recommendation of Googles style guide, that each
script must pass pylint2 without errors, is definitely worth considering.

$> pylint2 *.py */*.py */*/*.py
run inside the codeface directory shouldn't report that many
violations. And especially not that many actual errors.

that depends. Style violations are permitted if the results are
great (time is a bounded resource, and often these things don't
commute). A cleanup (and maybe some pre-commit hooks that can help
here) is nonetheless highly appreciated, and we should of course
try to not introduce more violations in the future.

Thanks, Wolfgang Mauerer


Greetings,
Andreas Ringlstetter

Best regards, Wolfgang Mauerer

else:
[computeSnapshotCollaboration(fileSnapShot[1],
[fileSnapShot[0]],



Other related posts: