-
Notifications
You must be signed in to change notification settings - Fork 313
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
Add props to prevent typos in config properties #1795
Conversation
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.
That's DRY indeed and looks fine :) I left small comments below. Can you confirm we could convert to underscores (e.g. list.config.option
-> list_config_option
) just by changes in PropEnum
and Property
classes in the future?
@gbanasiak Thank you for your comment. However, I became a bit suspicious that this hacky code is sustainable, even though I opened this PR. Also, if you plan to convert dot notations ( What do you think? Can we archive (close without merging and leave) this PR until this enum constants gets really crucial? |
@sakurai-youhei Thank you for iterating. I think #1798 is a step in the right direction. It will help working on #1795 or similar, and tighten existing use of configuration, but by itself will not fully address #1646 due to the following:
This wasn't stated explicitly but I've assumed we've embarked on the following journey:
I've already got accustomed to #1795 logic and don't find it hacky, but if you see a more straightforward solution we can pursue this instead. We already looked at 2 proposals earlier in #1646, and both were more repetitive in nature than this PR. We can obviously also close this draft if you don't want to invest more time in it. Enum constants are not a top priority. It is a nice to have feature of the code. Also, it is understood community contributions are not "guaranteed". It's your free time after all. The switch from dot notation to underscores is an option for the future, but I don't think we want to introduce such breaking change now. I was just confirming this proposal is flexible enough to accommodate this path, I think it is. |
Co-authored-by: Grzegorz Banasiak <[email protected]>
@gbanasiak Thank you for your comment. [1]
The above didn't come up in my mind, but that's a good idea indeed. [2]
Thinking about it over a long period, the answer is YES. The props can be reworked when the time will have come. I thought the switch would happen in the near future. But if it's not, I don't have anything other than this PR to achieve the DRY as of now. [3]
That's good to know. :) OK, I will resume working on this PR once #1798 gets done. |
I'm closing this PR to clean up my PR list. Please feel free to reopen PR and/or ping me anytime. P.S. Although @gbanasiak has welcomed this approach once, I've been questioning this PR by myself because of the hackiness. But I believe introducing mypy through #1798 was not a wrong decision. I appreciate the time and effort given to my PRs. Thank you very much. |
This PR will eliminate numerous strings around config by typo-proof enums.
In short,
cfg.opts("benchmarks", "local.dataset.cache")
will be rewritten to
cfg.opts(*props.BENCKMARKS.LOCAL.DATASET.CACHE)
The following points are aimed in the implementation:
-> i.e. With
props.SECTION.DOT.NOTATED.KEY
,func(*props.SECTION.DOT.NOTATED)
raisesTypeError
.In return, the following restrictions are introduced:
func(*props.SECTION.SPAM)
raisesTypeError
; you can still writefunc("section", "spam")
, though.camelCase
,PascalCase
,MACRO_CASE
,kebab-case
,COBOL-CASE
, andbracket[notation]
.Closes #1646
TODOs:
(section, key)
pairs.