Skip to content

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Nov 26, 2021

Add missing imports that were removed in #563

@@ -1,3 +1,6 @@
import os
import sys
Copy link
Member

Choose a reason for hiding this comment

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

scripts/init.py

AFAIK, it is not a standalone script. It is used through eval()

Copy link
Contributor Author

@cclauss cclauss Nov 26, 2021

Choose a reason for hiding this comment

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

eval() is evil ;-) but if these imports have already been done then these lines become no-ops but if the imports have not been done then these lines will prevent crashes.

Copy link
Contributor

Choose a reason for hiding this comment

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

@cclauss, you mean it prevents crashes in a linting job?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Crashes in any situation where os and sys have not already been imported by some other file.

As it says in The Zen of Python", explicit is better than implicit.

@asenyaev
Copy link
Contributor

I'm going to merge scripts/__init__.py to __init__.py in opencv repository to avoid keeping it in two different places and rewriting configs in setup.py.

@cclauss cclauss closed this Nov 29, 2021
@cclauss cclauss deleted the missing-imports branch November 29, 2021 14:25
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.

3 participants