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

Local tox checks do not skip #28612

Merged
merged 19 commits into from
Feb 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix the mypy invocation to properly error in and out of CI
  • Loading branch information
scbedd committed Feb 2, 2023
commit bbb1e8a4ebe5101696807c903f31b5e92bd4afcf
33 changes: 16 additions & 17 deletions eng/tox/run_mypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,24 @@
except CalledProcessError as src_err:
src_code_error = src_err

if in_ci():
if not is_check_enabled(args.target_package, "type_check_samples", True):
if in_ci() and not is_check_enabled(args.target_package, "type_check_samples", True):
logging.info(
f"Package {package_name} opts-out of mypy check on samples."
)
else:
sample_code = [
*commands,
"--check-untyped-defs",
"--follow-imports=silent",
os.path.join(args.target_package, "samples")
]
try:
logging.info(
f"Package {package_name} opts-out of mypy check on samples."
f"Running mypy commands on sample code: {sample_code}"
)
else:
sample_code = [
*commands,
"--check-untyped-defs",
"--follow-imports=silent",
os.path.join(args.target_package, "samples")
]
try:
logging.info(
f"Running mypy commands on sample code: {sample_code}"
)
check_call(sample_code)
except CalledProcessError as sample_err:
sample_code_error = sample_err
check_call(sample_code)
except CalledProcessError as sample_err:
sample_code_error = sample_err

print("See https://aka.ms/python/typing-guide for information.\n\n")
if src_code_error and sample_code_error:
Expand Down
6 changes: 1 addition & 5 deletions tools/azure-sdk-tools/ci_tools/environment_exclusions.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,6 @@
]




def is_check_enabled(package_path: str, check: str, default: bool = True) -> bool:
"""
Single-use function to evaluate whether or not a given check should run against a package.
Expand Down Expand Up @@ -381,7 +379,7 @@ def is_check_enabled(package_path: str, check: str, default: bool = True) -> boo
# now pull the new pyproject.toml configuration
config = get_config_setting(package_path, check.strip().lower(), True)

return (config and enabled)
return config and enabled


def filter_tox_environment_string(namespace_argument: str, package_path: str) -> str:
Expand All @@ -395,8 +393,6 @@ def filter_tox_environment_string(namespace_argument: str, package_path: str) ->
if package_path.endswith("setup.py"):
package_path = os.path.dirname(package_path)

package_name = os.path.basename(package_path)

if namespace_argument:
tox_envs = namespace_argument.strip().split(",")
filtered_set = []
Expand Down