Skip to content

Python3 support for restapi#2117

Merged
giovannipizzi merged 50 commits into
aiidateam:developfrom
waychal:python3_restapi
Oct 26, 2018
Merged

Python3 support for restapi#2117
giovannipizzi merged 50 commits into
aiidateam:developfrom
waychal:python3_restapi

Conversation

@waychal
Copy link
Copy Markdown
Contributor

@waychal waychal commented Oct 25, 2018

No description provided.

ltalirz and others added 30 commits October 23, 2018 10:50
select working version of PycCifRW for python2 and python3
_exportstring should return bytes.
to reflect this, we are renaming it and updating its docstring
errors were only converted to test failures
(the interactive part of the test is failing now)
still to do: fix base64 conversion
Functions affected:
1) test_contents_encoding_1()
2) cif_encode_contents
3) encode_textfield_quoted_printable
…ke them runnable both on Python 2 and Python 3.
Copy link
Copy Markdown
Member

@giovannipizzi giovannipizzi left a comment

Choose a reason for hiding this comment

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

Also try to reduce the number of exclusions when possible, thanks!

Comment thread aiida/restapi/resources.py Outdated
id=id,
query_string=request.query_string,
id=node_id,
query_string=query_string,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Before it was unquoted. Was it wrong before or now? Note there is another place in the code which has a similar pattern, good to check what is done there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Unquoted and quoted query string in response object both works in same way.

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-7.7%) to 60.888% when pulling 85308fb on waychal:python3_restapi into 9cceedb on aiidateam:develop.

@coveralls
Copy link
Copy Markdown

coveralls commented Oct 25, 2018

Coverage Status

Coverage increased (+7.7%) to 68.622% when pulling de993a0 on waychal:python3_restapi into 0f8721a on aiidateam:develop.

dev-zero
dev-zero previously approved these changes Oct 26, 2018
Copy link
Copy Markdown
Contributor

@dev-zero dev-zero left a comment

Choose a reason for hiding this comment

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

there is one common anti-pattern here:

def func(something=None):
  if something is None:
    something = "some default value"
  pass

where I would do instead:

def func(something="some default value"):
  pass

for k, v in headers.items():
response.headers[k] = v
for key, val in headers.items():
response.headers[key] = val
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

for next time, possibly use respone.headers.update(headers) as a shorthand

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here response.header is not a type of dict so we can not directly update it with another dictionary.


@staticmethod
def get_visualization_data(node, format=None):
def get_visualization_data(node, visformat=None):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why not put visformat="xsf" here directly? then its clear by looking at the signature of the function what the default is


@staticmethod
def get_downloadable_data(node, format=None):
def get_downloadable_data(node, download_format=None):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

... same here

@giovannipizzi
Copy link
Copy Markdown
Member

This fixes #2086

@giovannipizzi giovannipizzi merged commit d8fca45 into aiidateam:develop Oct 26, 2018
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.

7 participants