-
Notifications
You must be signed in to change notification settings - Fork 104
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
Added command line option to lint the configuration setup #5249
Added command line option to lint the configuration setup #5249
Conversation
Codecov Report
@@ Coverage Diff @@
## main #5249 +/- ##
==========================================
+ Coverage 73.20% 73.23% +0.03%
==========================================
Files 391 395 +4
Lines 26946 27100 +154
Branches 1965 1965
==========================================
+ Hits 19725 19846 +121
- Misses 6657 6690 +33
Partials 564 564
... and 18 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
b3435d5
to
0f457a7
Compare
0f457a7
to
efd4a45
Compare
cadc1e2
to
efa62f7
Compare
efa62f7
to
cf585bc
Compare
cf585bc
to
83f0112
Compare
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.
This is a good direction. I commented on some smaller issues. Generally I would like to see more tests as there is a lot of new functionality here. As for the general approach to the parser module, a second opinion by @mortalisk would be good.
8d30307
to
324e2f9
Compare
src/ert/parsing/config_keywords.py
Outdated
args: List[Any], | ||
keyword: FileContextToken, | ||
) -> Union[List[Any], Any]: | ||
errors = [] |
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.
Need to annotate this as errors: List[Union[ErrorInfo, ConfigValidationError]] = []
src/ert/parsing/config_keywords.py
Outdated
) | ||
if self.argc_max == 1 and self.argc_min == 1: | ||
|
||
elif self.argc_max == 1 and self.argc_min == 1: |
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.
This could return args[0]
with an error in the errors
list coming from token_to_value_with_context
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in case here it makes sense to check for errors before doing the return statement
by setting "ert" as the value to NUM_REALIZATIONS I got this. a repetition of the same error.
|
Fixed w/ test & some change to control flow, it happened due to 2 issues: (1) if a kw like NUM_REALIZATIONS is specified to "ert", it is now not added to the config_dict as it is invalid, then check_required does not find it in the config_dict and also flags it as undeclared which is not the case. Fix: have check_required take in a Set[str] of declared values, because it checks if something is declared, not if it is valid & parsed. (2) the alias NUM_REALISATIONS / NUM_REALIZATIONS caused a duplicate check in check_required, due to this: ...
for constraints in schema.values():
.... schema.values() returns the NUM_REALIZATIONS entry twice. visited: Set[str] = set()
for constraints in schema.values():
if constraints.kw in visited:
continue |
As for use of new() is intended mainly to allow subclasses of immutable types (like int, str, or tuple) to customize instance creation. It is also commonly overridden in custom metaclasses in order to customize class creation. So a subclass overriding the init of its immutable superclass will give an error when initialized with more arguments than that of its superclass. For |
specifically: NUM_REALIZATIONS in check_required
151cb9a
to
80a9807
Compare
src/ert/parsing/context_values.py
Outdated
token: FileContextToken | ||
keyword_token: FileContextToken | ||
|
||
def __init__(self, val: bool, token: str, keyword_token: FileContextToken): |
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.
Mypy complains about a mismatch of types in self.token = token
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.
Oops, should be FileContextToken, fixed
80a9807
to
59e484c
Compare
Remember to squash, and tick all the boxes |
62f15bb
to
0db17a0
Compare
0db17a0
to
fe69957
Compare
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.
Remember to squash and merge
Issue
Resolves #5248
Approach
Added command line option
ert lint
which just produces errors and warnings from the configuration file:Pre review checklist
Adding labels helps the maintainers when writing release notes. This is the list of release note labels.