Repository navigation
Conversation
|
ready for review. Until review comments are seen, the changes from here on will be only for codacy/ruff and other minor modifications as needed. |
MartinFlores751
left a comment
There was a problem hiding this comment.
Code is looking good to me, only have one suggestion. Learned about the := operator.
| # Set a number of metadata AVUs with the iRODSMeta builder invocation. (Each of | ||
| # these AVU values follow a predictable relation defined by the test_mapping function.) | ||
| def test_mapping(name): return str(ord(name)) | ||
| avu_names = [chr(_) for _ in range(ord('a'), ord('z')+1)] |
There was a problem hiding this comment.
Style question. Is it preferable to use _ here? I thought _ was equivalent to "discard this result" and was a bit surprised to see it work.
There was a problem hiding this comment.
_ is a valid dummy variable name, so our tools like it better than having a meaningfule variable like loopVariable because, you know, namespace pollution. Of course it's also true as of Python 3.x that list comprehension temporaries do not leak outward, so ... really we can choose anything.
_ , in the interpreter, means "last result". Other than that , I don't think there's any special meaning....
There was a problem hiding this comment.
Style question. Is it preferable to use
_here? I thought_was equivalent to "discard this result" and was a bit surprised to see it work.
now that I look at it though, [ letter for letter in string.ascii_lowercase ] might be more self-documenting - ?
There was a problem hiding this comment.
_ is a valid dummy variable name, so our tools like it better than having a meaningfule variable like
loopVariablebecause, you know, namespace pollution. Of course it's also true as of Python 3.x that list comprehension temporaries do not leak outward, so ... really we can choose anything.
_, in the interpreter, means "last result". Other than that , I don't think there's any special meaning....
Learned a lot about how _ is treated and scoping behavior here. Thanks for the info!
Style question. Is it preferable to use
_here? I thought_was equivalent to "discard this result" and was a bit surprised to see it work.now that I look at it though, [ letter for letter in string.ascii_lowercase ] might be more self-documenting - ?
Definitely like self-documenting code. If you think it'll help future readers, I'd change _ to letter.
| # data.metadata(admin = True) generates a cloned object but for the one change to "admin". | ||
| data.metadata.admin = True | ||
|
|
||
| def test_iRODSMeta_builder__issue_835(self): |
There was a problem hiding this comment.
Is this test about exercising basic functionality of the new builder?
| # Use both forms of the iRODSMeta builder invocation, testing that both attempts | ||
| # resulted in the AVU we expected. (For sets, s1 < s2 iff s1 is a proper subset of s2.) | ||
| data_obj.metadata['mile'] = iRODSMeta.builder(value=KM_PER_MILE, units='km') | ||
| data_obj.metadata['foot'] = iRODSMeta.builder(CM_PER_FOOT, 'cm') | ||
| self.assertLess( | ||
| { | ||
| iRODSMeta('mile', KM_PER_MILE, 'km'), | ||
| iRODSMeta('foot', CM_PER_FOOT, 'cm'), | ||
| }, | ||
| set(data_obj.metadata.items()) | ||
| ) |
There was a problem hiding this comment.
If I'm understanding correctly, set(data_obj.metadata.items()) will be the superset because it has more AVUs?
| With only one AVU on the object with a name of "key2", *get_one* | ||
| is assured of not throwing an exception: | ||
| Alternatively, in the indexed AVU assignment, the following construction can | ||
| be used in lieu of the direct call to the iRODSMeta constructor, thus avoiding redundant use of the |
There was a problem hiding this comment.
We need to determine if there's a pattern in how we style types and other important words. I suspect there are inconsistencies in the README.
| be used in lieu of the direct call to the iRODSMeta constructor, thus avoiding redundant use of the | |
| be used in lieu of the direct call to the `iRODSMeta` constructor, thus avoiding redundant use of the |
We need to do a consistency sweep across the READMEs. That can happen in a separate PR.
| any other pre-existing AVUs with a name field of 'key2' before the requested assignment is | ||
| actually made. | ||
|
|
||
| Be aware that use of the indexing form on obj.metadata to retrieve AVUs |
There was a problem hiding this comment.
| Be aware that use of the indexing form on obj.metadata to retrieve AVUs | |
| Be aware that use of the indexing form on `obj.metadata` to retrieve AVUs |
| ``` | ||
| x = obj.metadata['key1'] | ||
| ``` |
There was a problem hiding this comment.
Missing python styling keyword on opening backticks.
| ``` | ||
| >>> obj.metadata['key2'] = iRODSMeta.builder(value='value5', units='units2') | ||
| ``` |
There was a problem hiding this comment.
Missing python styling keyword on opening backticks.
| ``` | ||
|
|
||
| In versions of iRODS 4.2.12 and later, we can also do: | ||
| In iRODS 4.2.12 and after, a rodsadmin can apply the ADMIN_KW |
There was a problem hiding this comment.
| In iRODS 4.2.12 and after, a rodsadmin can apply the ADMIN_KW | |
| In iRODS 4.2.12 and after, a rodsadmin can apply the `ADMIN_KW` |
| actually made. | ||
|
|
||
| Be aware that use of the indexing form on obj.metadata to retrieve AVUs | ||
| with code such as |
There was a problem hiding this comment.
Add colon after "as"? Noticed other places in this diff had a colon.
| with code such as | |
| with code such as: |
|
|
||
| For these reasons, the indexed assignment may be better considered an artifact of convenience | ||
| rather than reliable, straightforward coding practice. For clear and unambiguous intent, the | ||
| canonical iRODS API endpoints should be used, with calls such as |
There was a problem hiding this comment.
Add colon after "as"? Noticed other places in this diff had a colon.
| canonical iRODS API endpoints should be used, with calls such as | |
| canonical iRODS API endpoints should be used, with calls such as: |
No description provided.