Skip to content

style: use 'is None' instead of '== None' per PEP 8#79

Open
haosenwang1018 wants to merge 1 commit intoHKUDS:mainfrom
haosenwang1018:fix/none-comparison-idiom
Open

style: use 'is None' instead of '== None' per PEP 8#79
haosenwang1018 wants to merge 1 commit intoHKUDS:mainfrom
haosenwang1018:fix/none-comparison-idiom

Conversation

@haosenwang1018
Copy link

Summary

Replace == None with is None across 3 files, following PEP 8 guidance:

Comparisons to singletons like None should always be done with is or is not, never the equality operators.

Changes

File Line Before After
autoagent/tools/meta/edit_workflow.py 131 == None is None
constant.py 14 == None is None
evaluation/math500/run_infer.py 36, 96 == None is None

Why

Using == for None checks can produce incorrect results if an object overrides __eq__. is None is both safer and idiomatic Python.

PEP 8 recommends using 'is None' / 'is not None' for singleton
comparisons since None is a singleton object. Using '==' can give
unexpected results if __eq__ is overridden.

Files changed:
- autoagent/tools/meta/edit_workflow.py
- constant.py
- evaluation/math500/run_infer.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant