-
Notifications
You must be signed in to change notification settings - Fork 84
Update pylint version to match pyomo (v 3.3.9) #1684
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
Conversation
|
After looking at each test, I think that the warnings can be disabled globally. Currently, I have disabled on each line, but after reviewing, they can be generalized |
| return blk.chemical_flow_mass[t, j] == pyunits.convert( | ||
| chemical_dosage * blk.properties[t].flow_vol, | ||
| chemical_dosage | ||
| * blk.properties[t].flow_vol, # don't fully understand this test |
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 would appreciate someone else looking at this test. @bknueven do you recall this model?
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 fine, if clunky.
That said, I think in many, many places, instead of suppressing pylint we should instead add an additional else clause which raises an exception. WaterTAP is big enough that we should have our own exceptions anyways.
E.g., in this case the else clause could raise a WaterTAPDeveloperError, or if we want to be cute, a FronzenPipes error. It doesn't even need a message if we know we'll never hit the else clause upon inspection.
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.
Thank you for taking a look and sounds good-- suppressing was a temporary step and throwing a dev error makes sense.
| molecule = "" | ||
| if len(components) == 1: | ||
| molecule = components[0] | ||
| elif len(components) == 2: |
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 this is another case where we should raise an exception if neither condition is satisfied.
watertap/core/util/initialization.py
Outdated
| # can fix by initizalizing msg or can disable message | ||
| msg = "Message failed to initialize." |
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 would probably just replace the else clause with a generic WaterTAPDeveloperError because the issue is that the else clause is calling a message that hasn't necessarily been initialized yet, right?
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 remember there was a reason we did a msg here and not an error or log ... I think
watertap/costing/unit_models/gac.py
Outdated
| # contactor_cost_coeff_data, other_cost_param_data, energy_consumption_coeff_data = ( | ||
| # {}, | ||
| # {}, | ||
| # {}, | ||
| # ) # other option is to initialize as empty dicts and fill based on contactor type |
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 this solution is fine
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.
Just confirming, this solution meaning the initializing empty dicts
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.
Yes
watertap/unit_models/uv_aop.py
Outdated
| # take a look at this test together | ||
| iscale.set_scaling_factor( | ||
| self.uv_intensity, sf # pylint: disable=used-before-assignment | ||
| ) |
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.
Not sure what you mean by this comment
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.
Mostly referring to the comment about the if statement below. Needed more eyes in particular on this test
watertap/unit_models/uv_aop.py
Outdated
| iscale.set_scaling_factor( | ||
| self.exposure_time, sf | ||
| ) # why is this one set inside the if but none of the rest? |
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.
Good catch - this should not be inside the if statement
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.
Shouldn't all be inside the if statement? I think the fact that they are outside is causing the sf possibly used before assignment error
I simply disabled for now since the comment above says that an error would be thrown elsewhere
watertap/costing/unit_models/gac.py
Outdated
| # contactor_cost_coeff_data, other_cost_param_data, energy_consumption_coeff_data = ( | ||
| # {}, | ||
| # {}, | ||
| # {}, | ||
| # ) # other option is to initialize as empty dicts and fill based on contactor type |
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.
Just confirming, this solution meaning the initializing empty dicts
watertap/unit_models/uv_aop.py
Outdated
| # take a look at this test together | ||
| iscale.set_scaling_factor( | ||
| self.uv_intensity, sf # pylint: disable=used-before-assignment | ||
| ) |
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.
Mostly referring to the comment about the if statement below. Needed more eyes in particular on this test
watertap/unit_models/uv_aop.py
Outdated
| iscale.set_scaling_factor( | ||
| self.exposure_time, sf | ||
| ) # why is this one set inside the if but none of the rest? |
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.
Shouldn't all be inside the if statement? I think the fact that they are outside is causing the sf possibly used before assignment error
I simply disabled for now since the comment above says that an error would be thrown elsewhere
bknueven
left a comment
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.
Thanks @sufikaur. I found a few more small things, but I think this is about ready.
watertap/unit_models/uv_aop.py
Outdated
| ) | ||
| iscale.set_scaling_factor( | ||
| self.exposure_time, sf | ||
| ) # why is this one set inside the if but none of the rest? |
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 the answer here is this one is correct, and the other are wrong. The code doesn't make sense otherwise, right?
watertap/unit_models/uv_aop.py
Outdated
| ) | ||
| iscale.set_scaling_factor(self.exposure_time, sf) | ||
|
|
||
| iscale.set_scaling_factor(self.exposure_time, sf) |
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.
Just to reiterate -- I think all the calls to set_scaling_factor in this method should be inside the associated if statement. That's on the only way this code makes sense.
watertap/costing/unit_models/gac.py
Outdated
| contactor_cost_coeff_data, other_cost_param_data, energy_consumption_coeff_data = ( | ||
| {}, | ||
| {}, | ||
| {}, | ||
| ) |
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 this is another one of those times we should raise an exception in an else. Otherwise we will get an error elsewhere and it'll be difficult to trace back here.
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.
changed this to an else
Co-authored-by: MarcusHolly <[email protected]>
| # touch this var since it is required for this method | ||
| self.conc_mol_phase_comp | ||
|
|
||
| """this could also be defined 'state_var["Liq", adjust_by_ion].fix(ion_adjusted)' |
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.
what is this doc string / comment???
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.
removed
| elif ix_type == "anion": | ||
| resin_cost = ion_exchange_params.anion_exchange_resin_cost | ||
| else: | ||
| raise WaterTapDeveloperError( |
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 gets checked in the unit model directly via checking of the charge on a component. It should be essentially impossible to get to this point.
... but maybe that is the point of a developer error?
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.
Yes. If somebody changes something upstream which breaks that assumption, we'll catch it here instead of just charging forward.
watertap/core/util/initialization.py
Outdated
| # can fix by initizalizing msg or can disable message | ||
| msg = "Message failed to initialize." |
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 remember there was a reason we did a msg here and not an error or log ... I think
Fixes/Resolves:
Issue 1679
See idaes PR 1683
Summary/Motivation:
Changes proposed in this PR:
Legal Acknowledgement
By contributing to this software project, I agree to the following terms and conditions for my contribution: