gh-138230: Remove dead code in code gen - codegen_check_annotation is only calle… (#138228)
Some checks are pending
Tests / Windows MSI (push) Blocked by required conditions
Tests / (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Ubuntu SSL tests with AWS-LC (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
mypy / Run mypy on Lib/_pyrepl (push) Waiting to run
mypy / Run mypy on Lib/test/libregrtest (push) Waiting to run
mypy / Run mypy on Lib/tomllib (push) Waiting to run
mypy / Run mypy on Tools/build (push) Waiting to run
mypy / Run mypy on Tools/cases_generator (push) Waiting to run
mypy / Run mypy on Tools/clinic (push) Waiting to run
mypy / Run mypy on Tools/jit (push) Waiting to run
mypy / Run mypy on Tools/peg_generator (push) Waiting to run

Remove dead code in code gen - codegen_check_annotation is only called if future annotations are enabled, and if future annotations are enabled it does nothing.
This commit is contained in:
Dino Viehland 2025-09-09 18:17:00 -07:00 committed by GitHub
parent 766e7f150a
commit 04c7f36205
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5414,23 +5414,6 @@ codegen_check_ann_expr(compiler *c, expr_ty e)
return SUCCESS;
}
static int
codegen_check_annotation(compiler *c, stmt_ty s)
{
/* Annotations of complex targets does not produce anything
under annotations future */
if (FUTURE_FEATURES(c) & CO_FUTURE_ANNOTATIONS) {
return SUCCESS;
}
/* Annotations are only evaluated in a module or class. */
if (SCOPE_TYPE(c) == COMPILE_SCOPE_MODULE ||
SCOPE_TYPE(c) == COMPILE_SCOPE_CLASS) {
return codegen_check_ann_expr(c, s->v.AnnAssign.annotation);
}
return SUCCESS;
}
static int
codegen_check_ann_subscr(compiler *c, expr_ty e)
{
@ -5524,10 +5507,6 @@ codegen_annassign(compiler *c, stmt_ty s)
targ->kind);
return ERROR;
}
/* Annotation is evaluated last. */
if (future_annotations && !s->v.AnnAssign.simple && codegen_check_annotation(c, s) < 0) {
return ERROR;
}
return SUCCESS;
}