-
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) #264
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.13%.
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! |
Codecov Report
@@ Coverage Diff @@
## wip-NXPY--Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 #264 +/- ##
======================================================================================================================================
- Coverage 94.48% 94.44% -0.05%
======================================================================================================================================
Files 29 29
Lines 1939 1925 -14
======================================================================================================================================
- Hits 1832 1818 -14
Misses 107 107
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. |
dd4e532
to
6bc11b4
Compare
3dc7abb
to
af2cff4
Compare
6bc11b4
to
29a80d6
Compare
af2cff4
to
a795647
Compare
29a80d6
to
eea7138
Compare
3a87552
to
8976964
Compare
8976964
to
fd6c4dd
Compare
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
)
doc.move(WORKSPACE_ROOT + "/Test2", "new_name") | ||
assert WORKSPACE_ROOT + "/Test2/new_name" in doc.path | ||
doc.move(f"{WORKSPACE_ROOT}/Test2", "new_name") | ||
assert f"{WORKSPACE_ROOT}/Test2/new_name" in doc.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.
Function test_document_move
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
self.url = nuxeo_url + "site/automation" | ||
self.url = f"{nuxeo_url}site/automation" |
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 ResponseAutomation.__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? ):
# 'pageNo' type == int
# 'end' type == str
# unknown param
# 'pageSize' type == int
# 'file' type == str
# 'info' type == dict
# 'value' type == Sequence
# 'query' type == str
# 'validationMethod' type == str
# 'queryParams' type in [list, str]
# 'blockInheritance' type == boolean
# 'properties' type == dict
# 'target' type == list
# 'file' type in (Blob, str)
# 'queryParams' is also optional, None should be accepted
# 'value' type == str
# 'startPage', 'endPage' type == long
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
)
6a7b19c
to
d44a4e0
Compare
fd6c4dd
to
1667c31
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 f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
) - Use named expression to simplify assignment and conditional (
use-named-expression
) - Remove unnecessary call to keys() (
remove-dict-keys
)
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:
- Merge dictionary updates via the union operator (
dict-assign-update-to-union
) - Use named expression to simplify assignment and conditional (
use-named-expression
) - Swap if/else branches of if expression to remove negation (
swap-if-expression
) - Remove unnecessary call to keys() (
remove-dict-keys
)
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
)
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
)
doc.move(WORKSPACE_ROOT + "/Test2", "new_name") | ||
assert WORKSPACE_ROOT + "/Test2/new_name" in doc.path | ||
doc.move(f"{WORKSPACE_ROOT}/Test2", "new_name") | ||
assert f"{WORKSPACE_ROOT}/Test2/new_name" in doc.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.
Function test_document_move
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
self.url = nuxeo_url + "site/automation" | ||
self.url = f"{nuxeo_url}site/automation" |
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 ResponseAutomation.__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
# 'blockInheritance' type == boolean
# 'file' type == str
# 'pageSize' type == int
# 'queryParams' type in [list, str]
# 'queryParams' is also optional, None should be accepted
# 'startPage', 'endPage' type == long
# 'pageNo' type == int
# 'target' type == list
# 'value' type == Sequence
# 'validationMethod' type == str
# 'file' type in (Blob, str)
# 'value' type == str
# 'end' type == str
# unknown param
# 'info' type == dict
# 'query' type == str
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
)
d44a4e0
to
fc7c67c
Compare
1667c31
to
603736a
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 f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
) - Use named expression to simplify assignment and conditional (
use-named-expression
) - Remove unnecessary call to keys() (
remove-dict-keys
)
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:
- Merge dictionary updates via the union operator (
dict-assign-update-to-union
) - Use named expression to simplify assignment and conditional (
use-named-expression
) - Swap if/else branches of if expression to remove negation (
swap-if-expression
) - Remove unnecessary call to keys() (
remove-dict-keys
)
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
)
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
)
doc.move(WORKSPACE_ROOT + "/Test2", "new_name") | ||
assert WORKSPACE_ROOT + "/Test2/new_name" in doc.path | ||
doc.move(f"{WORKSPACE_ROOT}/Test2", "new_name") | ||
assert f"{WORKSPACE_ROOT}/Test2/new_name" in doc.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.
Function test_document_move
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
self.url = nuxeo_url + "site/automation" | ||
self.url = f"{nuxeo_url}site/automation" |
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 ResponseAutomation.__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? ):
# 'blockInheritance' type == boolean
# 'end' type == str
# 'file' type in (Blob, str)
# 'pageSize' type == int
# 'info' type == dict
# 'file' type == str
# 'target' type == list
# 'validationMethod' type == str
# 'value' type == Sequence
# 'value' type == str
# 'startPage', 'endPage' type == long
# 'properties' type == dict
# 'queryParams' type in [list, str]
# 'pageNo' type == int
# unknown param
# 'queryParams' is also optional, None should be accepted
# 'query' type == str
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
)
fc7c67c
to
89e25dd
Compare
603736a
to
1b49366
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 f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
) - Use named expression to simplify assignment and conditional (
use-named-expression
) - Remove unnecessary call to keys() (
remove-dict-keys
)
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:
- Merge dictionary updates via the union operator (
dict-assign-update-to-union
) - Use named expression to simplify assignment and conditional (
use-named-expression
) - Swap if/else branches of if expression to remove negation (
swap-if-expression
) - Remove unnecessary call to keys() (
remove-dict-keys
)
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
)
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
)
doc.move(WORKSPACE_ROOT + "/Test2", "new_name") | ||
assert WORKSPACE_ROOT + "/Test2/new_name" in doc.path | ||
doc.move(f"{WORKSPACE_ROOT}/Test2", "new_name") | ||
assert f"{WORKSPACE_ROOT}/Test2/new_name" in doc.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.
Function test_document_move
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
self.url = nuxeo_url + "site/automation" | ||
self.url = f"{nuxeo_url}site/automation" |
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 ResponseAutomation.__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? ):
# 'queryParams' is also optional, None should be accepted
# unknown param
# 'end' type == str
# 'blockInheritance' type == boolean
# 'queryParams' type in [list, str]
# 'value' type == str
# 'pageSize' type == int
# 'file' type == str
# 'target' type == list
# 'query' type == str
# 'properties' type == dict
# 'startPage', 'endPage' type == long
# 'value' type == Sequence
# 'file' type in (Blob, str)
# 'info' type == dict
# 'validationMethod' type == 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
)
Pull Request #263 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--Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2
branch, then run:Help us improve this pull request!