-
-
-
-
-
-
Can you switch this to using Python format strings while you're at it? It'll be important for localization later.
-
-
Should only be indented 4 spaces, relative to "values." The trailing } should be aligned with "values".
-
-
-
-
-
-
These won't work with Python 2.4. It should stay how it was. Same with the ones below. Isn't this a 3.0 thing?
Some cleanups in 'api' branch
Review Request #2400 — Created June 15, 2011 and submitted
The patch fixes very basic issues of 'api' branch enough to make rb-create work. Also new config parser was implemented for rb-config using 'optparse' module.
Tested by hand and eyes.
Description | From | Last Updated |
---|---|---|
This won't work for Windows. |
chipx86 | |
Need to use os.path.join() to build paths. |
chipx86 | |
Blank line between these. |
chipx86 | |
Can't use the "as" form. |
chipx86 | |
Can you switch this to using Python format strings while you're at it? It'll be important for localization later. |
chipx86 | |
Here too. |
chipx86 | |
Should only be indented 4 spaces, relative to "values." The trailing } should be aligned with "values". |
chipx86 | |
"Filter out the values that are None." |
chipx86 | |
No space after "[" and before "]". |
chipx86 | |
Blank line before this. You can just do: if valid: |
chipx86 | |
You can just do: for name, value in valid: |
chipx86 | |
Blank line between these. |
chipx86 | |
These won't work with Python 2.4. It should stay how it was. Same with the ones below. Isn't this a … |
chipx86 | |
Not sure I understand this documentation. How about just "First load global options, and then local options. Also, proper capitalization. |
mike_conley | |
Needs proper capitalization. |
mike_conley | |
I think some quick documentation on what each of these methods tests would be fantastic. :) |
mike_conley | |
See above, re single block quote. Maybe for this, you can put: """Tests that we can set arbitrary attributes on … |
mike_conley | |
Some documentation would be great here, as well as in the class methods. |
mike_conley | |
Space before the if block |
mike_conley | |
Needs documentation - just a quick sentence on what this class does. If you could toss in some documentation for … |
mike_conley | |
Blank line after this. |
chipx86 | |
No need for \ |
chipx86 | |
Blank line after this. |
chipx86 | |
Should use super. |
chipx86 | |
Should use sentence casing, and have a period. |
chipx86 | |
Blank line between these. |
chipx86 | |
Blank line between these. |
chipx86 | |
Blank line between these. |
chipx86 | |
No need for parens. Blank line after this. |
chipx86 | |
Blank line between these. |
chipx86 | |
Only one space after import. |
chipx86 | |
Needs to be one line, and should be short. |
chipx86 | |
No blank line here. |
chipx86 | |
Didn't think we still had this. Or we shouldn't anyway. Like the SCMClients, it should import straight from the module … |
chipx86 | |
assertRegexpMatches isn't in Python 2.4. |
chipx86 | |
Can't depend on with. It's only in newer Pythons than we support. |
chipx86 | |
No blank line here. |
chipx86 | |
Should be two blank lines here. |
chipx86 | |
Indentation is broken. |
chipx86 | |
Probably didn't mean to leave this in? |
chipx86 | |
This seems... Very weird. Can't it just be: for name in opts: uuid = self.gen_uuid() args.append(...) ... |
chipx86 | |
Should probably use parens. |
chipx86 | |
Should use parens. |
chipx86 | |
Should use parens. |
chipx86 | |
If this is going to be used by code outside of this class, it should be a public function (no … |
chipx86 | |
Should use parens. |
chipx86 | |
This would actually be better as a pre-compiled regex constant as part of the class, like: DATE_RE = re.compile(r'....') ... … |
chipx86 | |
Are these intended to be in this change? |
chipx86 | |
Should be "accessed". |
mike_conley | |
Space after #, and capitalize first letter of first word. Same for comments below. |
mike_conley | |
I'm not 100% sure we need this success variable. The only time it's ever used, it's guaranteed to be True. … |
mike_conley | |
Wait - hold up, why can't we commit? |
mike_conley | |
Linebreaks before and after this if block. |
mike_conley | |
Linebreak after this else block |
mike_conley | |
Linebreak before this if-block |
mike_conley | |
Linebreak after this if block |
mike_conley | |
print isn't a function, and unlike if statements, we tend to just use \ print "No supported ".... \ "supplied … |
chipx86 | |
The compile should be a constant on the class, like: DATE_RE = re.compile(...) Also, "compile," not "complie". |
chipx86 | |
This isn't part of your original change, but while you're here, "json" is only on Python 2.6. So instead, do: … |
chipx86 |
- Change Summary:
-
Met all notes from the last review, added test cases for rbtools.api and rbtools.commands.
-
-
Where are the call sites of these methods you're removing? Are there none? By the way, I can't see the branch you refer to on github. Is it on a fork? Which one? What is the branch for?
-
If you pass in the config file paths rather than putting this code in the constructor, the tests don't need to rely on the current working directory (nor on conventions about cwd, ~, etc. that might change over time and aren't relevant to most of the tests). If you want to test that the current working directory is used as a default, you can test that separately in a single test. Since it's nice to have the minimal amount of code possible depend on such global state, it might be better to move the getcwd() call out of this class (especially since that could change). Nice talk about this: http://www.youtube.com/watch?v=-FRm3VPhseI
-
Every time you make a Settings object you immediately call .load on it -- except here. Is that a mistake? Why not just let Settings load when it needs to (e.g. in the constructor)?
-
It's nice that this is an explicit method rather than ad-hoc code in the tests. It would be even better if it cleaned up at the end of the test case (by removing the temporary directory -- and chdir-ing back to the original cwd, if the chdir is really necessary). The same goes for the other methods here that touch global state. One nice way to do that is to implement these using a method similar to unittest2's .addCleanup(). Here's a really simple implementation of that idea: http://lackingrhoticity.blogspot.com/2008/11/tempdirtestcase-python-unittest-helper.html
-
-
-
-
-
-
Why not make the option dest the same as the config file here? It seems confusing to present the user with two names for the same setting. If you do that, you can use optparse.make_option (and the .dest attribute of optparse.Option), which would allow eliminating the repetition of the dest values.
-
-
If it's going to print anything at all on success, maybe move this to after the setattr and have it print something that explicitly says what it has done, e.g. "Set %s : %s"?
-
This isn't very helpful to the user: $ rb config Usage: rb config [options] Maybe print_help() instead?
-
-
Alexander: This is looking really solid to me! Just a few nits, and some documentation requests. Thanks, -Mike
-
typo: "<name> is a valid option" - also, instead of two block quote passages, maybe this could be a single? See: https://github.com/reviewboard/reviewboard/blob/b5209aabf67994f8613844fa20dbdd55eab07a87/reviewboard/webapi/resources.py#L810 for example. Also, please properly capitalize in your documentation.
-
Not sure I understand this documentation. How about just "First load global options, and then local options. Also, proper capitalization.
-
-
-
See above, re single block quote. Maybe for this, you can put: """Tests that we can set arbitrary attributes on an instance of Settings. """
-
-
-
Needs documentation - just a quick sentence on what this class does. If you could toss in some documentation for the methods as well, that'd be awesome. :)
- Change Summary:
-
- rbtools/testutils.py renamed to rbtools/util/testutil.py - written description for tests - fixed style issues
-
So there's a number of specific style comments, but I have a few main points: 1) This seems to use a lot of old code (RBUtilities, for example) instead of the newer modules that you put into place with the SCMClients change. It doesn't look like it's merged with master? 2) I'm concerned this change is doing too much. It's fixing style issues, modifying stuff in SCMClients, adding a whole new settings framework, adding unit tests, adding unrelated TODOs (for git). It's the perfect example of a change that should be split up. I'd advise splitting up the settings stuff into its own change, after fixing the things below, and having another change solely for the style changes and comment additions. I'd also advise having a change just for the new unit test utils. I know that seems like extra work when you already have it all written, but we're going to have to get things in little by little, and when you have a really large change and we notice a regression or problem down the line, it makes it far more difficult to track it. Bite-sized changes that implement one thing are way easier all around. As a more general comment, if a change can be put onto master (style changes, maybe unit test utils), it'd be good to target it there instead of api. That results in less we end up merging in from api, making that easier to maintain as well.
-
Important note: This can't be required, or we'll break a *lot* of companies. I don't know how ConfigParser works, but if it absolutely has to have an INI section header, we can't use it here. Actually, come to think of it, we can't use ConfigParser. We need the .reviewboardrc files to work as they always have been. That is, they need to be essentially Python scripts. Many companies depend on them to be executable in order to fix up proxy issues and stuff. So that can't change.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Didn't think we still had this. Or we shouldn't anyway. Like the SCMClients, it should import straight from the module it's in. Same with all other instances.
-
-
-
-
-
-
-
This seems... Very weird. Can't it just be: for name in opts: uuid = self.gen_uuid() args.append(...) ...
-
Can you explain some of the motivation for this change? Why the change from utils to util? And files to fs? It seems like there are things in here that probably weren't supposed to be part of this review request.
-
-
-
-
If this is going to be used by code outside of this class, it should be a public function (no _ prefix), and shouldn't be "internal." However, this seems to be something that should be in a different review request, since it's not really cleanup, is it?
-
-
This would actually be better as a pre-compiled regex constant as part of the class, like: DATE_RE = re.compile(r'....') ... m = self.DATE_RE.search(dl[1])
-
-
Alexander: This looks pretty good! I agree with Christian, however - this change should probably be broken up into two or more diffs. I've noticed that some changes are purely cosmetic / stylistic (cleaning whitespace, reducing lines to <= 80 chars), while other changes have deeper potential impacts (renaming, new code, etc). Maybe you can split along those lines. All the best, -Mike
-
-
-
I'm not 100% sure we need this success variable. The only time it's ever used, it's guaranteed to be True. I think the var can be dropped, and just return true on line 410.
-
-
-
-
-
Just about there! One small style things, and a couple critical problems.
-
print isn't a function, and unlike if statements, we tend to just use \ print "No supported ".... \ "supplied url." (Always break on full words.)
-
The compile should be a constant on the class, like: DATE_RE = re.compile(...) Also, "compile," not "complie".
-
This isn't part of your original change, but while you're here, "json" is only on Python 2.6. So instead, do: try: from json import dumps except ImportError: from simplejson import dumps