Skip to content

Commit

Permalink
Enable deprecation warnings on external code
Browse files Browse the repository at this point in the history
edk2 invocables consume and execute external code. This includes the
settings file and the plugins.  These changes enable deprecation
warnings for those imported modules so that developers can see when they
are using deprecated code.
  • Loading branch information
Javagedes committed Aug 17, 2023
1 parent 6c5662b commit a1e2903
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions edk2toolext/edk2_invocable.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import logging
import os
import sys
import warnings
from random import choice
from string import ascii_letters
from textwrap import dedent
Expand Down Expand Up @@ -391,6 +392,9 @@ def ParseCommandLineOptions(self):
print(e)
sys.exit(2)

# Turn on Deprecation warnings for code in the module
warnings.filterwarnings("default", category=DeprecationWarning, module=self.PlatformModule.__name__)

# instantiate the second argparser that will get passed around
parserObj = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter,)

Expand Down
4 changes: 4 additions & 0 deletions edk2toolext/environment/plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import logging
import os
import sys
import warnings

from edk2toolext.environment import shell_environment

Expand Down Expand Up @@ -101,6 +102,9 @@ def _load(self, PluginDescriptor):
if py_module_dir not in sys.path:
sys.path.append(py_module_dir)

# Turn on Deprecation warnings for code in the plugin
warnings.filterwarnings("default", category=DeprecationWarning, module=module.__name__)

spec.loader.exec_module(module)
except Exception:
exc_info = sys.exc_info()
Expand Down

0 comments on commit a1e2903

Please sign in to comment.