Skip to content
This repository was archived by the owner on Aug 29, 2019. It is now read-only.

Conversation

@mdruger
Copy link

@mdruger mdruger commented Feb 14, 2014

Update code layout to AWeber coding standards.

The edits below are the changes I thought should be made. However, the entire code set should be reviewed to find areas that were missed.

@bkjones
Copy link

bkjones commented Feb 14, 2014

I did a cursory review only, of only the changes that were made. The nature of the card you're working on requires that the code review actually cover all of the entire files in the event that there were changes not made that should've been to bring the code base in line with our coding standards - @JohnBrodie or @chrismcguire or another stickler still needs to go over this. ;-)

Choose a reason for hiding this comment

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

These should be alphabetized.

@JohnBrodie
Copy link

@mdruger I'll do a more "holistic" review of this Monday, just wanted to get the ball rolling so you aren't blocked.

@JohnBrodie
Copy link

aweber_api/response.py:30:1: W391 blank line at end of file

@JohnBrodie
Copy link

There are a few spots in the code like aweber_api/collection.__init__ where we should be using super instead of the old-style method of calling parent methods.

@JohnBrodie
Copy link

In aweber_api/collection (and likely other places) we do:

import aweber_api
from aweber_api.response import AWeberResponse

We generally try to be as specific as possible with the imports.

@JohnBrodie
Copy link

aweber_api/__init__.py has imports in _read_response. They should be moved to the top of the file, assuming they aren't placed there for circular import reasons...

@JohnBrodie
Copy link

I'm not sure if this is out of scope, but since you're touching the whole codebase, I'll mention it. There are a bunch of "todo"/"we should test this"/"find a better way to do this" in the code, it'd be great if we could make decisions on the comments one way or the other, act on those decisions, and remove the extraneous comments.

@JohnBrodie
Copy link

@mdruger That's all I got.

@JohnBrodie
Copy link

Tests fail locally, and on Travis https://travis-ci.org/aweber/AWeber-API-Python-Library/pull_requests

@JohnBrodie
Copy link

Not sure how this is passing on Travis - the Mock package is being imported, but isn't in setup.py test_requires section. python setup.py develop && python setup.py nosetests fails in a clean virtualenv.

miked: ok, for this changeset, I will keep dingus. When the tests are updated, I will replace dingus.

Choose a reason for hiding this comment

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

This is going to blow up L99 with a TypeError.

Copy link
Author

Choose a reason for hiding this comment

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

I will rewrite this function

@JohnBrodie
Copy link

For what it's worth, the commits to update to using Mock didn't need ripped out, Mock just needed added to setup.py. If you'd prefer to do that in a different PR, that's fine though.

Choose a reason for hiding this comment

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

We usually catch specific exceptions, not the base Exception type.

Copy link
Author

Choose a reason for hiding this comment

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

I'll catch the AttributeError

@JohnBrodie
Copy link

From flake8:

aweber_api/__init__.py:11: W402 'AWeberCollection' imported but unused
aweber_api/__init__.py:12: W402 'AWeberEntry' imported but unused
aweber_api/__init__.py:14: W402 'AWeberResponse' imported but unused
aweber_api/collection.py:4: W402 'collections' imported but unused
aweber_api/collection.py:130:38: E225 missing whitespace around operator
aweber_api/collection.py:134:28: E225 missing whitespace around operator

miked: I addressed the collections and missing whitespace issues. Thanks for verifying the imported and unused modules with me.

Choose a reason for hiding this comment

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

This is less than ideal. We are taking apart the URL above, and then very slowly and oddly reassembling it, creating a bunch of extra string objects along the way, and throwing in some magic numbers for good measure... Is there not a URL parsing lib we could be using here?

Copy link
Author

Choose a reason for hiding this comment

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

I agree. The trouble here is that the variable 'url' is a misnomer in this case. We aren't actually manipulating an entire url string that includes the protocol, netloc, path, and all the other parameters that urlparse determines. The url looks something like this '/accounts/1/lists/1'. As awesome as urlparse is, using it here only returns the equivalent path string which has to use the split method to tokenize the string with the '/' delimiter (i.e. url_parts = url.split('/')). I will try a different string manipulation method that hopefully, will be easier to follow. What is even more confusing is that the string manipulation will change depending on whether the host class is an entry or a collection. I found away to place this in the base class, by adding a parameter to acknowledge the different class.

Mike Druger added 3 commits March 7, 2014 15:54
code standard update for __init__ and base class
code standard update for collection class.
code std update for entry class

Choose a reason for hiding this comment

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

Single quotes preferred over double quotes.

JohnBrodie pushed a commit that referenced this pull request Mar 10, 2014
Update to coding standard
@JohnBrodie JohnBrodie merged commit 4492251 into master Mar 10, 2014
@JohnBrodie JohnBrodie deleted the coding-std branch March 10, 2014 18:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants