-
Notifications
You must be signed in to change notification settings - Fork 4
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
NXPY-238: Fix issue with Self signed certificates (Sourcery refactored) #274
Conversation
Sourcery AI seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.17%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Help us improve this quality report! |
b11c650
to
a8b56fc
Compare
94ef9d7
to
bf31ac0
Compare
a8b56fc
to
fb418e3
Compare
bf31ac0
to
015a563
Compare
self.url = nuxeo_url + "1.0%20GiB.mov" | ||
self.url = f"{nuxeo_url}1.0%20GiB.mov" |
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.
Function ResponseMov.__init__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
self.url = nuxeo_url + "8.3%20GiB.mxf" | ||
self.url = f"{nuxeo_url}8.3%20GiB.mxf" |
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.
Function ResponseMxf.__init__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
self.url = nuxeo_url + "big%20file.txt" | ||
self.url = f"{nuxeo_url}big%20file.txt" |
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.
Function ResponseTextError.__init__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
self.url = nuxeo_url + "small%20file.txt" | ||
self.url = f"{nuxeo_url}small%20file.txt" |
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.
Function ResponseTextOk.__init__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
self.url = nuxeo_url + "big%20file.txt" | ||
self.url = f"{nuxeo_url}big%20file.txt" |
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.
Function ResponseTextTooLong.__init__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
@pytest.mark.parametrize( | ||
"method, params, is_valid", | ||
[ | ||
# 'file' type in (Blob, str) | ||
("Document.SetBlob", {"file": Blob()}, True), | ||
("Document.SetBlob", {"file": "test.txt"}, True), | ||
("Document.SetBlob", {"file": 0}, False), | ||
# 'blockInheritance' type == boolean | ||
( | ||
@pytest.mark.parametrize("method, params, is_valid", [("Document.SetBlob", {"file": Blob()}, True), ("Document.SetBlob", {"file": "test.txt"}, True), ("Document.SetBlob", {"file": 0}, False), ( | ||
"Document.AddPermission", | ||
{"permission": "Read", "blockInheritance": False}, | ||
True, | ||
), | ||
( | ||
), ( | ||
"Document.AddPermission", | ||
{"permission": "Read", "blockInheritance": "false"}, | ||
False, | ||
), | ||
# 'end' type == str | ||
("Document.AddPermission", {"permission": "Read", "end": "01-01-2018"}, True), | ||
("Document.AddPermission", {"permission": "Read", "end": True}, False), | ||
# 'value' type == str | ||
("Document.Fetch", {"value": "test.txt"}, True), | ||
("Document.Fetch", {"value": True}, False), | ||
# 'target' type == list | ||
("Document.MultiPublish", {"target": ["test1.txt", "test2.txt"]}, True), | ||
("Document.MultiPublish", {"target": 0}, False), | ||
# 'pageNo' type == int | ||
("Audit.Query", {"query": "test", "pageNo": 100}, True), | ||
# 'pageSize' type == int | ||
("Audit.Query", {"query": "test", "pageNo": "test"}, False), | ||
("Document.Query", {"query": "test", "pageSize": 10}, True), | ||
("Document.Query", {"query": "test", "pageSize": "test"}, False), | ||
# 'startPage', 'endPage' type == long | ||
("PDF.ExtractPages", {"startPage": 1, "endPage": int(2)}, True), | ||
("PDF.ExtractPages", {"startPage": "test", "endPage": "test"}, False), | ||
# 'info' type == dict | ||
("User.Invite", {"info": {"username": "test"}}, True), | ||
("User.Invite", {"info": 0}, False), | ||
# 'properties' type == dict | ||
( | ||
), ("Document.AddPermission", {"permission": "Read", "end": "01-01-2018"}, True), ("Document.AddPermission", {"permission": "Read", "end": True}, False), ("Document.Fetch", {"value": "test.txt"}, True), ("Document.Fetch", {"value": True}, False), ("Document.MultiPublish", {"target": ["test1.txt", "test2.txt"]}, True), ("Document.MultiPublish", {"target": 0}, False), ("Audit.Query", {"query": "test", "pageNo": 100}, True), ("Audit.Query", {"query": "test", "pageNo": "test"}, False), ("Document.Query", {"query": "test", "pageSize": 10}, True), ("Document.Query", {"query": "test", "pageSize": "test"}, False), ("PDF.ExtractPages", {"startPage": 1, "endPage": 2}, True), ("PDF.ExtractPages", {"startPage": "test", "endPage": "test"}, False), ("User.Invite", {"info": {"username": "test"}}, True), ("User.Invite", {"info": 0}, False), ( | ||
"Document.Create", | ||
{"type": "Document", "properties": {"dc:title": "test"}}, | ||
True, | ||
), | ||
("Document.Create", {"type": "Document", "properties": 0}, False), | ||
# 'file' type == str | ||
("Blob.Create", {"file": "test.txt"}, True), | ||
("Blob.Create", {"file": 0}, False), | ||
# 'value' type == Sequence | ||
("Document.SetProperty", {"xpath": "test", "value": "test"}, True), | ||
("Document.SetProperty", {"xpath": "test", "value": [0, 1, 2]}, True), | ||
("Document.SetProperty", {"xpath": "test", "value": 0}, False), | ||
# 'query' type == str | ||
("Document.Query", {"query": "test"}, True), | ||
("Document.Query", {"query": 0}, False), | ||
# 'queryParams' type in [list, str] | ||
("Document.Query", {"query": "test", "queryParams": ["a", "b", "c"]}, True), | ||
("Document.Query", {"query": "test", "queryParams": "test"}, True), | ||
("Document.Query", {"query": "test", "queryParams": 0}, False), | ||
# 'queryParams' is also optional, None should be accepted | ||
("Document.Query", {"query": "test", "queryParams": None}, True), | ||
# 'validationMethod' type == str | ||
("User.Invite", {"validationMethod": "test"}, True), | ||
("User.Invite", {"validationMethod": 0}, False), | ||
# unknown param | ||
("Document.Query", {"alien": "alien"}, False), | ||
], | ||
) | ||
), ("Document.Create", {"type": "Document", "properties": 0}, False), ("Blob.Create", {"file": "test.txt"}, True), ("Blob.Create", {"file": 0}, False), ("Document.SetProperty", {"xpath": "test", "value": "test"}, True), ("Document.SetProperty", {"xpath": "test", "value": [0, 1, 2]}, True), ("Document.SetProperty", {"xpath": "test", "value": 0}, False), ("Document.Query", {"query": "test"}, True), ("Document.Query", {"query": 0}, False), ("Document.Query", {"query": "test", "queryParams": ["a", "b", "c"]}, True), ("Document.Query", {"query": "test", "queryParams": "test"}, True), ("Document.Query", {"query": "test", "queryParams": 0}, False), ("Document.Query", {"query": "test", "queryParams": None}, True), ("User.Invite", {"validationMethod": "test"}, True), ("User.Invite", {"validationMethod": 0}, False), ("Document.Query", {"alien": "alien"}, False)]) |
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.
Function test_check_params
refactored with the following changes:
- Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast
)
This removes the following comments ( why? ):
# 'startPage', 'endPage' type == long
# 'value' type == Sequence
# 'query' type == str
# 'properties' type == dict
# 'value' type == str
# 'blockInheritance' type == boolean
# 'pageSize' type == int
# unknown param
# 'queryParams' type in [list, str]
# 'end' type == str
# 'queryParams' is also optional, None should be accepted
# 'target' type == list
# 'validationMethod' type == str
# 'info' type == dict
# 'file' type == str
# 'file' type in (Blob, str)
# 'pageNo' type == int
rsps.add(responses.GET, server.client.host + "json/cmis", body="...") | ||
rsps.add(responses.GET, f"{server.client.host}json/cmis", body="...") |
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.
Function test_server_info_bad_response
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
rsps.add(responses.GET, server.client.host + "json/cmis", body="...") | ||
rsps.add(responses.GET, f"{server.client.host}json/cmis", body="...") |
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.
Function test_server_version_bad_response_from_server_info
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
assert len(aces) in (2, 3) | ||
assert len(aces) in {2, 3} |
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.
Function test_fetch_acls
refactored with the following changes:
- Use set when checking membership of a collection of literals (
collection-into-set
)
file_out = filename + ".dl" | ||
file_out = f"{filename}.dl" |
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.
Function download_file
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
Codecov ReportBase: 93.98% // Head: 94.07% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## wip-NXPY-238-Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 #274 +/- ##
=========================================================================================================================================
+ Coverage 93.98% 94.07% +0.08%
=========================================================================================================================================
Files 26 26
Lines 1763 1754 -9
=========================================================================================================================================
- Hits 1657 1650 -7
+ Misses 106 104 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
fb418e3
to
52a3226
Compare
015a563
to
29df423
Compare
"User-Agent": app_name + "/" + version, | ||
"User-Agent": f"{app_name}/{version}", | ||
"Accept": "application/json, */*", | ||
} | ||
|
||
self.schemas = kwargs.get("schemas", "*") | ||
self.repository = kwargs.pop("repository", "default") | ||
self._session = requests.sessions.Session() | ||
self._session.hooks["response"] = [log_response] | ||
cookies = kwargs.pop("cookies", None) | ||
if cookies: | ||
if cookies := kwargs.pop("cookies", None): | ||
self._session.cookies = cookies | ||
self._session.stream = True | ||
self.client_kwargs = kwargs | ||
|
||
self.ssl_verify_needed = True | ||
if "verify" in kwargs.keys(): | ||
if "verify" in kwargs: |
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.
Function NuxeoClient.__init__
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
) - Remove unnecessary call to keys() (
remove-dict-keys
) - Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
data.update(params) | ||
data |= params | ||
|
||
url = self.api_path + "/search/lang/NXQL/execute" | ||
url = f"{self.api_path}/search/lang/NXQL/execute" |
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.
Function NuxeoClient.query
refactored with the following changes:
- Merge dictionary updates via the union operator (
dict-assign-update-to-union
) - Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
kwargs.update(self.client_kwargs) | ||
kwargs |= self.client_kwargs |
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.
Function NuxeoClient.request
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
) - Merge dictionary updates via the union operator (
dict-assign-update-to-union
) - Remove unnecessary call to keys() (
remove-dict-keys
) - Swap if/else branches of if expression to remove negation (
swap-if-expression
)
error_data.update(response.json()) | ||
error_data |= response.json() |
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.
Function NuxeoClient._handle_error
refactored with the following changes:
- Merge dictionary updates via the union operator (
dict-assign-update-to-union
)
kwargs.update(params) | ||
kwargs |= params |
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.
Function API.get
refactored with the following changes:
- Merge dictionary updates via the union operator (
dict-assign-update-to-union
)
if y_numbers: | ||
return -1 | ||
|
||
return 0 | ||
return -1 if y_numbers else 0 |
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.
Function version_compare
refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else
) - Replace if statement with if expression (
assign-if-exp
)
to_upload = set(range(1, self.chunk_count + 1, 1)) - set( | ||
to_upload = set(range(1, self.chunk_count + 1)) - set( | ||
self.blob.uploadedChunkIds | ||
) | ||
|
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.
Function ChunkUploaderS3._compute_chunks_left
refactored with the following changes:
- Replace range(x, y, 1) with range(x, y) (
remove-unit-step-from-range
)
WORKSPACE_TEST = WORKSPACE_ROOT + "/" + WORKSPACE_NAME | ||
WORKSPACE_TEST = f"{WORKSPACE_ROOT}/{WORKSPACE_NAME}" |
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.
Lines 5-5
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
operation.params = {"document": WORKSPACE_ROOT + "/Document"} | ||
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"} |
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.
Function test_digester
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
params={"document": WORKSPACE_ROOT + "/Document"}, | ||
params={"document": f"{WORKSPACE_ROOT}/Document"}, | ||
) | ||
|
||
if SSL_VERIFY is False: | ||
doc = server.documents.get( | ||
path=WORKSPACE_ROOT + "/Document", ssl_verify=False | ||
) | ||
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document", ssl_verify=False) | ||
else: | ||
doc = server.documents.get(path=WORKSPACE_ROOT + "/Document") | ||
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document") |
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.
Function test_execute
refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
)
if SSL_VERIFY is False: | ||
blob = batch.get(0, ssl_verify=False) | ||
else: | ||
blob = batch.get(0) | ||
blob = batch.get(0, ssl_verify=False) if SSL_VERIFY is False else batch.get(0) |
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.
Function test_fetch
refactored with the following changes:
- Replace if statement with if expression [×2] (
assign-if-exp
)
operation.params = {"document": WORKSPACE_ROOT + "/Document"} | ||
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"} | ||
if SSL_VERIFY is False: | ||
operation.input_obj = batch.get(0, ssl_verify=False) | ||
else: | ||
operation.input_obj = batch.get(0) | ||
operation.execute() | ||
if SSL_VERIFY is False: | ||
doc = server.documents.get( | ||
path=WORKSPACE_ROOT + "/Document", ssl_verify=False | ||
) | ||
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document", ssl_verify=False) | ||
else: | ||
doc = server.documents.get(path=WORKSPACE_ROOT + "/Document") | ||
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document") |
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.
Function test_operation
refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
)
operation.params = {"document": WORKSPACE_ROOT + "/Document"} | ||
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"} |
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.
Function test_upload
refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
)
operation.params = {"document": WORKSPACE_ROOT + "/Document"} | ||
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"} |
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.
Function test_upload_several_callbacks
refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
)
input_obj="doc:" + WORKSPACE_ROOT, | ||
input_obj=f"doc:{WORKSPACE_ROOT}", | ||
type="Note", | ||
name=name, | ||
properties=properties, | ||
) | ||
|
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.
Function test_document_create_bytes_warning
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
self.url = nuxeo_url + "8.3%20GiB.mxf" | ||
self.url = f"{nuxeo_url}8.3%20GiB.mxf" |
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.
Function ResponseMxf.__init__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
self.url = nuxeo_url + "big%20file.txt" | ||
self.url = f"{nuxeo_url}big%20file.txt" |
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.
Function ResponseTextError.__init__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
self.url = nuxeo_url + "small%20file.txt" | ||
self.url = f"{nuxeo_url}small%20file.txt" |
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.
Function ResponseTextOk.__init__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
self.url = nuxeo_url + "big%20file.txt" | ||
self.url = f"{nuxeo_url}big%20file.txt" |
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.
Function ResponseTextTooLong.__init__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
@pytest.mark.parametrize( | ||
"method, params, is_valid", | ||
[ | ||
# 'file' type in (Blob, str) | ||
("Document.SetBlob", {"file": Blob()}, True), | ||
("Document.SetBlob", {"file": "test.txt"}, True), | ||
("Document.SetBlob", {"file": 0}, False), | ||
# 'blockInheritance' type == boolean | ||
( | ||
@pytest.mark.parametrize("method, params, is_valid", [("Document.SetBlob", {"file": Blob()}, True), ("Document.SetBlob", {"file": "test.txt"}, True), ("Document.SetBlob", {"file": 0}, False), ( | ||
"Document.AddPermission", | ||
{"permission": "Read", "blockInheritance": False}, | ||
True, | ||
), | ||
( | ||
), ( | ||
"Document.AddPermission", | ||
{"permission": "Read", "blockInheritance": "false"}, | ||
False, | ||
), | ||
# 'end' type == str | ||
("Document.AddPermission", {"permission": "Read", "end": "01-01-2018"}, True), | ||
("Document.AddPermission", {"permission": "Read", "end": True}, False), | ||
# 'value' type == str | ||
("Document.Fetch", {"value": "test.txt"}, True), | ||
("Document.Fetch", {"value": True}, False), | ||
# 'target' type == list | ||
("Document.MultiPublish", {"target": ["test1.txt", "test2.txt"]}, True), | ||
("Document.MultiPublish", {"target": 0}, False), | ||
# 'pageNo' type == int | ||
("Audit.Query", {"query": "test", "pageNo": 100}, True), | ||
# 'pageSize' type == int | ||
("Audit.Query", {"query": "test", "pageNo": "test"}, False), | ||
("Document.Query", {"query": "test", "pageSize": 10}, True), | ||
("Document.Query", {"query": "test", "pageSize": "test"}, False), | ||
# 'startPage', 'endPage' type == long | ||
("PDF.ExtractPages", {"startPage": 1, "endPage": int(2)}, True), | ||
("PDF.ExtractPages", {"startPage": "test", "endPage": "test"}, False), | ||
# 'info' type == dict | ||
("User.Invite", {"info": {"username": "test"}}, True), | ||
("User.Invite", {"info": 0}, False), | ||
# 'properties' type == dict | ||
( | ||
), ("Document.AddPermission", {"permission": "Read", "end": "01-01-2018"}, True), ("Document.AddPermission", {"permission": "Read", "end": True}, False), ("Document.Fetch", {"value": "test.txt"}, True), ("Document.Fetch", {"value": True}, False), ("Document.MultiPublish", {"target": ["test1.txt", "test2.txt"]}, True), ("Document.MultiPublish", {"target": 0}, False), ("Audit.Query", {"query": "test", "pageNo": 100}, True), ("Audit.Query", {"query": "test", "pageNo": "test"}, False), ("Document.Query", {"query": "test", "pageSize": 10}, True), ("Document.Query", {"query": "test", "pageSize": "test"}, False), ("PDF.ExtractPages", {"startPage": 1, "endPage": 2}, True), ("PDF.ExtractPages", {"startPage": "test", "endPage": "test"}, False), ("User.Invite", {"info": {"username": "test"}}, True), ("User.Invite", {"info": 0}, False), ( | ||
"Document.Create", | ||
{"type": "Document", "properties": {"dc:title": "test"}}, | ||
True, | ||
), | ||
("Document.Create", {"type": "Document", "properties": 0}, False), | ||
# 'file' type == str | ||
("Blob.Create", {"file": "test.txt"}, True), | ||
("Blob.Create", {"file": 0}, False), | ||
# 'value' type == Sequence | ||
("Document.SetProperty", {"xpath": "test", "value": "test"}, True), | ||
("Document.SetProperty", {"xpath": "test", "value": [0, 1, 2]}, True), | ||
("Document.SetProperty", {"xpath": "test", "value": 0}, False), | ||
# 'query' type == str | ||
("Document.Query", {"query": "test"}, True), | ||
("Document.Query", {"query": 0}, False), | ||
# 'queryParams' type in [list, str] | ||
("Document.Query", {"query": "test", "queryParams": ["a", "b", "c"]}, True), | ||
("Document.Query", {"query": "test", "queryParams": "test"}, True), | ||
("Document.Query", {"query": "test", "queryParams": 0}, False), | ||
# 'queryParams' is also optional, None should be accepted | ||
("Document.Query", {"query": "test", "queryParams": None}, True), | ||
# 'validationMethod' type == str | ||
("User.Invite", {"validationMethod": "test"}, True), | ||
("User.Invite", {"validationMethod": 0}, False), | ||
# unknown param | ||
("Document.Query", {"alien": "alien"}, False), | ||
], | ||
) | ||
), ("Document.Create", {"type": "Document", "properties": 0}, False), ("Blob.Create", {"file": "test.txt"}, True), ("Blob.Create", {"file": 0}, False), ("Document.SetProperty", {"xpath": "test", "value": "test"}, True), ("Document.SetProperty", {"xpath": "test", "value": [0, 1, 2]}, True), ("Document.SetProperty", {"xpath": "test", "value": 0}, False), ("Document.Query", {"query": "test"}, True), ("Document.Query", {"query": 0}, False), ("Document.Query", {"query": "test", "queryParams": ["a", "b", "c"]}, True), ("Document.Query", {"query": "test", "queryParams": "test"}, True), ("Document.Query", {"query": "test", "queryParams": 0}, False), ("Document.Query", {"query": "test", "queryParams": None}, True), ("User.Invite", {"validationMethod": "test"}, True), ("User.Invite", {"validationMethod": 0}, False), ("Document.Query", {"alien": "alien"}, False)]) |
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.
Function test_check_params
refactored with the following changes:
- Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast
)
This removes the following comments ( why? ):
# 'query' type == str
# 'blockInheritance' type == boolean
# 'info' type == dict
# 'end' type == str
# 'file' type in (Blob, str)
# 'file' type == str
# 'startPage', 'endPage' type == long
# 'queryParams' is also optional, None should be accepted
# 'properties' type == dict
# 'target' type == list
# 'value' type == str
# 'pageNo' type == int
# 'pageSize' type == int
# unknown param
# 'queryParams' type in [list, str]
# 'validationMethod' type == str
# 'value' type == Sequence
rsps.add(responses.GET, server.client.host + "json/cmis", body="...") | ||
rsps.add(responses.GET, f"{server.client.host}json/cmis", body="...") |
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.
Function test_server_info_bad_response
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
rsps.add(responses.GET, server.client.host + "json/cmis", body="...") | ||
rsps.add(responses.GET, f"{server.client.host}json/cmis", body="...") |
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.
Function test_server_version_bad_response_from_server_info
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
assert len(aces) in (2, 3) | ||
assert len(aces) in {2, 3} |
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.
Function test_fetch_acls
refactored with the following changes:
- Use set when checking membership of a collection of literals (
collection-into-set
)
file_out = filename + ".dl" | ||
file_out = f"{filename}.dl" |
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.
Function download_file
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
52a3226
to
3ef327e
Compare
29df423
to
e241573
Compare
"User-Agent": app_name + "/" + version, | ||
"User-Agent": f"{app_name}/{version}", | ||
"Accept": "application/json, */*", | ||
} | ||
|
||
self.schemas = kwargs.get("schemas", "*") | ||
self.repository = kwargs.pop("repository", "default") | ||
self._session = requests.sessions.Session() | ||
self._session.hooks["response"] = [log_response] | ||
cookies = kwargs.pop("cookies", None) | ||
if cookies: | ||
if cookies := kwargs.pop("cookies", None): | ||
self._session.cookies = cookies | ||
self._session.stream = True | ||
self.client_kwargs = kwargs | ||
|
||
self.ssl_verify_needed = True | ||
if "verify" in kwargs.keys(): | ||
if "verify" in kwargs: |
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.
Function NuxeoClient.__init__
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
) - Remove unnecessary call to keys() (
remove-dict-keys
) - Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
data.update(params) | ||
data |= params | ||
|
||
url = self.api_path + "/search/lang/NXQL/execute" | ||
url = f"{self.api_path}/search/lang/NXQL/execute" |
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.
Function NuxeoClient.query
refactored with the following changes:
- Merge dictionary updates via the union operator (
dict-assign-update-to-union
) - Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
kwargs.update(self.client_kwargs) | ||
kwargs |= self.client_kwargs |
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.
Function NuxeoClient.request
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
) - Merge dictionary updates via the union operator (
dict-assign-update-to-union
) - Remove unnecessary call to keys() (
remove-dict-keys
) - Swap if/else branches of if expression to remove negation (
swap-if-expression
)
error_data.update(response.json()) | ||
error_data |= response.json() |
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.
Function NuxeoClient._handle_error
refactored with the following changes:
- Merge dictionary updates via the union operator (
dict-assign-update-to-union
)
kwargs.update(params) | ||
kwargs |= params |
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.
Function API.get
refactored with the following changes:
- Merge dictionary updates via the union operator (
dict-assign-update-to-union
)
if y_numbers: | ||
return -1 | ||
|
||
return 0 | ||
return -1 if y_numbers else 0 |
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.
Function version_compare
refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else
) - Replace if statement with if expression (
assign-if-exp
)
to_upload = set(range(1, self.chunk_count + 1, 1)) - set( | ||
to_upload = set(range(1, self.chunk_count + 1)) - set( | ||
self.blob.uploadedChunkIds | ||
) | ||
|
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.
Function ChunkUploaderS3._compute_chunks_left
refactored with the following changes:
- Replace range(x, y, 1) with range(x, y) (
remove-unit-step-from-range
)
WORKSPACE_TEST = WORKSPACE_ROOT + "/" + WORKSPACE_NAME | ||
WORKSPACE_TEST = f"{WORKSPACE_ROOT}/{WORKSPACE_NAME}" |
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.
Lines 5-5
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
operation.params = {"document": WORKSPACE_ROOT + "/Document"} | ||
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"} |
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.
Function test_digester
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
params={"document": WORKSPACE_ROOT + "/Document"}, | ||
params={"document": f"{WORKSPACE_ROOT}/Document"}, | ||
) | ||
|
||
if SSL_VERIFY is False: | ||
doc = server.documents.get( | ||
path=WORKSPACE_ROOT + "/Document", ssl_verify=False | ||
) | ||
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document", ssl_verify=False) | ||
else: | ||
doc = server.documents.get(path=WORKSPACE_ROOT + "/Document") | ||
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document") |
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.
Function test_execute
refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
)
if SSL_VERIFY is False: | ||
blob = batch.get(0, ssl_verify=False) | ||
else: | ||
blob = batch.get(0) | ||
blob = batch.get(0, ssl_verify=False) if SSL_VERIFY is False else batch.get(0) |
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.
Function test_fetch
refactored with the following changes:
- Replace if statement with if expression [×2] (
assign-if-exp
)
operation.params = {"document": WORKSPACE_ROOT + "/Document"} | ||
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"} | ||
if SSL_VERIFY is False: | ||
operation.input_obj = batch.get(0, ssl_verify=False) | ||
else: | ||
operation.input_obj = batch.get(0) | ||
operation.execute() | ||
if SSL_VERIFY is False: | ||
doc = server.documents.get( | ||
path=WORKSPACE_ROOT + "/Document", ssl_verify=False | ||
) | ||
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document", ssl_verify=False) | ||
else: | ||
doc = server.documents.get(path=WORKSPACE_ROOT + "/Document") | ||
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document") |
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.
Function test_operation
refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
)
operation.params = {"document": WORKSPACE_ROOT + "/Document"} | ||
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"} |
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.
Function test_upload
refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
)
operation.params = {"document": WORKSPACE_ROOT + "/Document"} | ||
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"} |
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.
Function test_upload_several_callbacks
refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
)
input_obj="doc:" + WORKSPACE_ROOT, | ||
input_obj=f"doc:{WORKSPACE_ROOT}", | ||
type="Note", | ||
name=name, | ||
properties=properties, | ||
) | ||
|
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.
Function test_document_create_bytes_warning
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
self.url = nuxeo_url + "8.3%20GiB.mxf" | ||
self.url = f"{nuxeo_url}8.3%20GiB.mxf" |
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.
Function ResponseMxf.__init__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
self.url = nuxeo_url + "big%20file.txt" | ||
self.url = f"{nuxeo_url}big%20file.txt" |
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.
Function ResponseTextError.__init__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
self.url = nuxeo_url + "small%20file.txt" | ||
self.url = f"{nuxeo_url}small%20file.txt" |
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.
Function ResponseTextOk.__init__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
self.url = nuxeo_url + "big%20file.txt" | ||
self.url = f"{nuxeo_url}big%20file.txt" |
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.
Function ResponseTextTooLong.__init__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
@pytest.mark.parametrize( | ||
"method, params, is_valid", | ||
[ | ||
# 'file' type in (Blob, str) | ||
("Document.SetBlob", {"file": Blob()}, True), | ||
("Document.SetBlob", {"file": "test.txt"}, True), | ||
("Document.SetBlob", {"file": 0}, False), | ||
# 'blockInheritance' type == boolean | ||
( | ||
@pytest.mark.parametrize("method, params, is_valid", [("Document.SetBlob", {"file": Blob()}, True), ("Document.SetBlob", {"file": "test.txt"}, True), ("Document.SetBlob", {"file": 0}, False), ( | ||
"Document.AddPermission", | ||
{"permission": "Read", "blockInheritance": False}, | ||
True, | ||
), | ||
( | ||
), ( | ||
"Document.AddPermission", | ||
{"permission": "Read", "blockInheritance": "false"}, | ||
False, | ||
), | ||
# 'end' type == str | ||
("Document.AddPermission", {"permission": "Read", "end": "01-01-2018"}, True), | ||
("Document.AddPermission", {"permission": "Read", "end": True}, False), | ||
# 'value' type == str | ||
("Document.Fetch", {"value": "test.txt"}, True), | ||
("Document.Fetch", {"value": True}, False), | ||
# 'target' type == list | ||
("Document.MultiPublish", {"target": ["test1.txt", "test2.txt"]}, True), | ||
("Document.MultiPublish", {"target": 0}, False), | ||
# 'pageNo' type == int | ||
("Audit.Query", {"query": "test", "pageNo": 100}, True), | ||
# 'pageSize' type == int | ||
("Audit.Query", {"query": "test", "pageNo": "test"}, False), | ||
("Document.Query", {"query": "test", "pageSize": 10}, True), | ||
("Document.Query", {"query": "test", "pageSize": "test"}, False), | ||
# 'startPage', 'endPage' type == long | ||
("PDF.ExtractPages", {"startPage": 1, "endPage": int(2)}, True), | ||
("PDF.ExtractPages", {"startPage": "test", "endPage": "test"}, False), | ||
# 'info' type == dict | ||
("User.Invite", {"info": {"username": "test"}}, True), | ||
("User.Invite", {"info": 0}, False), | ||
# 'properties' type == dict | ||
( | ||
), ("Document.AddPermission", {"permission": "Read", "end": "01-01-2018"}, True), ("Document.AddPermission", {"permission": "Read", "end": True}, False), ("Document.Fetch", {"value": "test.txt"}, True), ("Document.Fetch", {"value": True}, False), ("Document.MultiPublish", {"target": ["test1.txt", "test2.txt"]}, True), ("Document.MultiPublish", {"target": 0}, False), ("Audit.Query", {"query": "test", "pageNo": 100}, True), ("Audit.Query", {"query": "test", "pageNo": "test"}, False), ("Document.Query", {"query": "test", "pageSize": 10}, True), ("Document.Query", {"query": "test", "pageSize": "test"}, False), ("PDF.ExtractPages", {"startPage": 1, "endPage": 2}, True), ("PDF.ExtractPages", {"startPage": "test", "endPage": "test"}, False), ("User.Invite", {"info": {"username": "test"}}, True), ("User.Invite", {"info": 0}, False), ( | ||
"Document.Create", | ||
{"type": "Document", "properties": {"dc:title": "test"}}, | ||
True, | ||
), | ||
("Document.Create", {"type": "Document", "properties": 0}, False), | ||
# 'file' type == str | ||
("Blob.Create", {"file": "test.txt"}, True), | ||
("Blob.Create", {"file": 0}, False), | ||
# 'value' type == Sequence | ||
("Document.SetProperty", {"xpath": "test", "value": "test"}, True), | ||
("Document.SetProperty", {"xpath": "test", "value": [0, 1, 2]}, True), | ||
("Document.SetProperty", {"xpath": "test", "value": 0}, False), | ||
# 'query' type == str | ||
("Document.Query", {"query": "test"}, True), | ||
("Document.Query", {"query": 0}, False), | ||
# 'queryParams' type in [list, str] | ||
("Document.Query", {"query": "test", "queryParams": ["a", "b", "c"]}, True), | ||
("Document.Query", {"query": "test", "queryParams": "test"}, True), | ||
("Document.Query", {"query": "test", "queryParams": 0}, False), | ||
# 'queryParams' is also optional, None should be accepted | ||
("Document.Query", {"query": "test", "queryParams": None}, True), | ||
# 'validationMethod' type == str | ||
("User.Invite", {"validationMethod": "test"}, True), | ||
("User.Invite", {"validationMethod": 0}, False), | ||
# unknown param | ||
("Document.Query", {"alien": "alien"}, False), | ||
], | ||
) | ||
), ("Document.Create", {"type": "Document", "properties": 0}, False), ("Blob.Create", {"file": "test.txt"}, True), ("Blob.Create", {"file": 0}, False), ("Document.SetProperty", {"xpath": "test", "value": "test"}, True), ("Document.SetProperty", {"xpath": "test", "value": [0, 1, 2]}, True), ("Document.SetProperty", {"xpath": "test", "value": 0}, False), ("Document.Query", {"query": "test"}, True), ("Document.Query", {"query": 0}, False), ("Document.Query", {"query": "test", "queryParams": ["a", "b", "c"]}, True), ("Document.Query", {"query": "test", "queryParams": "test"}, True), ("Document.Query", {"query": "test", "queryParams": 0}, False), ("Document.Query", {"query": "test", "queryParams": None}, True), ("User.Invite", {"validationMethod": "test"}, True), ("User.Invite", {"validationMethod": 0}, False), ("Document.Query", {"alien": "alien"}, False)]) |
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.
Function test_check_params
refactored with the following changes:
- Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast
)
This removes the following comments ( why? ):
# 'properties' type == dict
# 'queryParams' is also optional, None should be accepted
# 'value' type == str
# 'target' type == list
# 'blockInheritance' type == boolean
# 'info' type == dict
# 'file' type == str
# 'queryParams' type in [list, str]
# unknown param
# 'startPage', 'endPage' type == long
# 'end' type == str
# 'file' type in (Blob, str)
# 'value' type == Sequence
# 'query' type == str
# 'validationMethod' type == str
# 'pageNo' type == int
# 'pageSize' type == int
rsps.add(responses.GET, server.client.host + "json/cmis", body="...") | ||
rsps.add(responses.GET, f"{server.client.host}json/cmis", body="...") |
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.
Function test_server_info_bad_response
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
rsps.add(responses.GET, server.client.host + "json/cmis", body="...") | ||
rsps.add(responses.GET, f"{server.client.host}json/cmis", body="...") |
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.
Function test_server_version_bad_response_from_server_info
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
assert len(aces) in (2, 3) | ||
assert len(aces) in {2, 3} |
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.
Function test_fetch_acls
refactored with the following changes:
- Use set when checking membership of a collection of literals (
collection-into-set
)
file_out = filename + ".dl" | ||
file_out = f"{filename}.dl" |
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.
Function download_file
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
Pull Request #273 refactored by Sourcery.
If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
wip-NXPY-238-Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2
branch, then run:Help us improve this pull request!