-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor code #53
Refactor code #53
Conversation
VitaliyaIoffe
commented
Dec 13, 2021
•
edited
Loading
edited
- isort
- flake8 refactoring
- typehinting
env_common_settings = {} | ||
env_common_settings['credentials'] = \ | ||
json.loads(os.environ.get('RWS_CREDENTIALS')) | ||
if (cred := os.environ.get('RWS_CREDENTIALS')) is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
be careful: this assignment is allowed from python 3.8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related with the commit.
given your comment, I would prefer it to stay the way it was.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so due to in case of staying with your way I should describe type manually. It is a wrong way I guess, otherwise, the type would be assigned dynamically.
s3repo/view.py
Outdated
|
||
return render_template('index.html', **list_parameters) | ||
|
||
@staticmethod | ||
def _get_file(path, response): | ||
def _get_file(path, response) -> Response: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path and response are not described
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path - str
response - described in https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Client.get_object as I understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! Thank you for the patchset.
Common comments:
- isort: sort imports -> lint: add sorting of imports with isort
I think this commit is pointless without adding a workflow to CI/CD. But really useful with adding to CI/CD. - flake8: fix style -> codestyle: fix style according flake8. The same point as in the previous one.
- typing: add typing -> codestyle: add typing. I think it's enough to specify the types for the arguments and return values of the functions. Specify types for internal variables - overkill.
@@ -1,5 +1,6 @@ | |||
"""Description of the uploaded / downloaded package.""" | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related with the commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
upd: have to fix
env_model_settings['secret_access_key'] = os.getenv('S3_SECRET_KEY') | ||
env_model_settings['public_read'] = get_bool_env('S3_PUBLIC_READ', False) | ||
env_model_settings['force_sync'] = get_bool_env('RWS_FORCE_SYNC', False) | ||
env_model_settings = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related with the commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't agree, see comments above
@@ -27,42 +28,43 @@ def _readable_size(size): | |||
return readable_size | |||
size /= 1024.0 | |||
|
|||
return "%3.1f B" % (size) | |||
return "%3.1f B" % size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related with the commit.
What's the code style rule being violated here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove redundant parentheses
'path': path, | ||
'parent_path': parent_path, | ||
'items': readable_items} | ||
list_parameters = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related with the commit.
s3repo/view.py
Outdated
|
||
return render_template('index.html', **list_parameters) | ||
|
||
@staticmethod | ||
def _get_file(path, response): | ||
def _get_file(path, response) -> Response: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path - str
response - described in https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Client.get_object as I understand.
s3repo/view.py
Outdated
"""Show a directory or download a file according to the | ||
"subpath" path. | ||
def dispatch_request(self, subpath='/') -> Response: | ||
"""Show a directory or download a file according to the "subpath" path. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related with the commit.
What's the code style rule being violated here?
Is such pull request still actual? |
Yep. The author planned to finish it. |
The author is here again! But I am not a team member and can't push to the pr :( . What way should I use to finish? Use new pr from my repo? |
I temporary give you write access to finish this PR (sorry, I can't keep this permission forever). |
Not a problem. Thank you! |
07e83bc
to
fff4f87
Compare
Just rebased. It takes more time to finish. |
a3523bd
to
946e3d5
Compare
49675fc
to
56269a5
Compare
56269a5
to
6343809
Compare
Hi! Sorry I didn't review this patch in time. We are planning to migrate to nexus and archive this service, so no work is being done here other than bug fixes. |