Skip to content

Commit

Permalink
Merge pull request #209 from craigcitro/lint
Browse files Browse the repository at this point in the history
Fix lint errors in apitools.
  • Loading branch information
kevinli7 authored Mar 29, 2018
2 parents fd4a7b7 + 4857df3 commit 286e63d
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 1,288 deletions.
3 changes: 3 additions & 0 deletions apitools/base/protorpclite/protojson.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ def _load_json_module():

logging.error('Must use valid json library (json or simplejson)')
raise first_import_error # pylint:disable=raising-bad-type


json = _load_json_module()


Expand Down Expand Up @@ -368,6 +370,7 @@ def set_default(protocol):
raise TypeError('Expected protocol of type ProtoJson')
ProtoJson.__default = protocol


CONTENT_TYPE = ProtoJson.CONTENT_TYPE

ALTERNATIVE_CONTENT_TYPES = ProtoJson.ALTERNATIVE_CONTENT_TYPES
Expand Down
5 changes: 4 additions & 1 deletion apitools/base/py/base_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ class ApiMethodInfo(messages.Message):
request_field = messages.StringField(11, default='')
upload_config = messages.MessageField(ApiUploadInfo, 12)
supports_download = messages.BooleanField(13, default=False)


REQUEST_IS_BODY = '<request>'


Expand Down Expand Up @@ -239,7 +241,8 @@ def __init__(self, url, credentials=None, get_credentials=True, http=None,
model=None, log_request=False, log_response=False,
num_retries=5, max_retry_wait=60, credentials_args=None,
default_global_params=None, additional_http_headers=None,
check_response_func=None, retry_func=None, response_encoding=None):
check_response_func=None, retry_func=None,
response_encoding=None):
_RequireClassAttrs(self, ('_package', '_scopes', 'messages_module'))
if default_global_params is not None:
util.Typecheck(default_global_params, self.params_type)
Expand Down
1 change: 1 addition & 0 deletions apitools/base/py/base_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def DeclareBaseFlags():

_BASE_FLAGS_DECLARED = True


FLAGS = flags.FLAGS


Expand Down
2 changes: 2 additions & 0 deletions apitools/base/py/extra_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ def _DecodeInt64Field(unused_field, value):
# Don't need to do anything special, they're decoded just fine
return encoding.CodecResult(value=value, complete=False)


encoding.RegisterFieldTypeCodec(_EncodeInt64Field, _DecodeInt64Field)(
messages.IntegerField)

Expand All @@ -303,4 +304,5 @@ def _DecodeDateField(unused_field, value):
date = datetime.datetime.strptime(value, '%Y-%m-%d').date()
return encoding.CodecResult(value=date, complete=True)


encoding.RegisterFieldTypeCodec(_EncodeDateField, _DecodeDateField)(DateField)
1 change: 1 addition & 0 deletions apitools/gen/gen_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,5 +346,6 @@ def main(argv=None):
args = parser.parse_args(argv[1:])
return args.func(args) or 0


if __name__ == '__main__':
sys.exit(main())
4 changes: 2 additions & 2 deletions apitools/gen/message_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def LookupDescriptor(self, name):
def LookupDescriptorOrDie(self, name):
message_descriptor = self.LookupDescriptor(name)
if message_descriptor is None:
raise ValueError('No message descriptor named "%s"', name)
raise ValueError('No message descriptor named "%s"' % name)
return message_descriptor

def __GetDescriptor(self, name):
Expand Down Expand Up @@ -262,7 +262,7 @@ def AddDescriptorFromSchema(self, schema_name, schema):
self.__DeclareMessageAlias(schema, 'extra_types.JsonValue')
return
if schema.get('type') != 'object':
raise ValueError('Cannot create message descriptors for type %s',
raise ValueError('Cannot create message descriptors for type %s' %
schema.get('type'))
message = extended_descriptor.ExtendedMessageDescriptor()
message.name = self.__names.ClassName(schema['id'])
Expand Down
3 changes: 2 additions & 1 deletion apitools/gen/service_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ def WriteFile(self, printer):
printer('get_credentials=True, http=None, model=None,')
printer('log_request=False, log_response=False,')
printer('credentials_args=None, default_global_params=None,')
printer('additional_http_headers=None, response_encoding=None):')
printer('additional_http_headers=None, '
'response_encoding=None):')
with printer.Indent():
printer('"""Create a new %s handle."""', client_info.package)
printer('url = url or self.BASE_URL')
Expand Down
Loading

0 comments on commit 286e63d

Please sign in to comment.