Skip to content
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

Only perform check on param if value is given #228

Merged
merged 1 commit into from
Sep 22, 2021

Conversation

BrianJKoopman
Copy link
Member

Description

If a value isn't given, the check likely isn't valid. This will cause problems
if the decorated method is imported, for instance in any testing, as the value
will be None on import, which will fail simple checks like x < 100.

Example traceback when this happens:

tests/agents/test_ls372_agent.py:3: in <module>                                      
    from LS372_agent import LS372_Agent                                              
agents/lakeshore372/LS372_agent.py:70: in <module>                                   
    class LS372_Agent:                                                               
agents/lakeshore372/LS372_agent.py:585: in LS372_Agent                               
    ???                                                                              
../ocs/ocs/ocs_agent.py:1224: in param                                               
    ParamHandler({}).get(key, default=None, **kwargs)                                
../ocs/ocs/ocs_agent.py:1168: in get                                                 
    if not check(value):                                                             
agents/lakeshore372/LS372_agent.py:585: in <lambda>                                  
    ???                                                                              
E   TypeError: '<' not supported between instances of 'NoneType' and 'int'   

Motivation and Context

No open issue for this bug, found when developing tests for an socs Agent.

How Has This Been Tested?

The import in question above passes with this change.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • Unless I am preparing a release, I have opened this PR onto the develop branch.

If a value isn't given, the check likely isn't valid. This will cause problems
if the decorated method is imported, for instance in any testing, as the value
will be None on import, which will fail simple checks like x < 100.
@BrianJKoopman BrianJKoopman added the bug Something isn't working label Sep 21, 2021
Copy link
Member

@mhasself mhasself left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@BrianJKoopman BrianJKoopman merged commit 13be6e8 into develop Sep 22, 2021
@BrianJKoopman BrianJKoopman deleted the param-check-bug-fix branch September 22, 2021 14:27
@BrianJKoopman BrianJKoopman mentioned this pull request Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants