(self, s: AssignmentStmt)
| 3287 | return True |
| 3288 | |
| 3289 | def visit_assignment_stmt(self, s: AssignmentStmt) -> None: |
| 3290 | self.statement = s |
| 3291 | |
| 3292 | # Special case assignment like X = X. |
| 3293 | if self.analyze_identity_global_assignment(s): |
| 3294 | return |
| 3295 | |
| 3296 | tag = self.track_incomplete_refs() |
| 3297 | |
| 3298 | # Here we have a chicken and egg problem: at this stage we can't call |
| 3299 | # can_be_type_alias(), because we have not enough information about rvalue. |
| 3300 | # But we can't use a full visit because it may emit extra incomplete refs (namely |
| 3301 | # when analysing any type applications there) thus preventing the further analysis. |
| 3302 | # To break the tie, we first analyse rvalue partially, if it can be a type alias. |
| 3303 | if self.can_possibly_be_type_form(s): |
| 3304 | old_basic_type_applications = self.basic_type_applications |
| 3305 | self.basic_type_applications = True |
| 3306 | with self.allow_unbound_tvars_set(): |
| 3307 | s.rvalue.accept(self) |
| 3308 | self.basic_type_applications = old_basic_type_applications |
| 3309 | elif self.can_possibly_be_typevarlike_declaration(s): |
| 3310 | # Allow unbound tvars inside TypeVarLike defaults to be evaluated later |
| 3311 | with self.allow_unbound_tvars_set(): |
| 3312 | s.rvalue.accept(self) |
| 3313 | else: |
| 3314 | s.rvalue.accept(self) |
| 3315 | |
| 3316 | if self.found_incomplete_ref(tag) or self.should_wait_rhs(s.rvalue): |
| 3317 | # Initializer couldn't be fully analyzed. Defer the current node and give up. |
| 3318 | # Make sure that if we skip the definition of some local names, they can't be |
| 3319 | # added later in this scope, since an earlier definition should take precedence. |
| 3320 | for expr in names_modified_by_assignment(s): |
| 3321 | self.mark_incomplete(expr.name, expr) |
| 3322 | return |
| 3323 | if self.can_possibly_be_type_form(s): |
| 3324 | # Now re-visit those rvalues that were we skipped type applications above. |
| 3325 | # This should be safe as generally semantic analyzer is idempotent. |
| 3326 | with self.allow_unbound_tvars_set(): |
| 3327 | s.rvalue.accept(self) |
| 3328 | |
| 3329 | # The r.h.s. is now ready to be classified, first check if it is a special form: |
| 3330 | special_form = False |
| 3331 | # * type alias |
| 3332 | if self.check_and_set_up_type_alias(s): |
| 3333 | s.is_alias_def = True |
| 3334 | special_form = True |
| 3335 | elif isinstance(s.rvalue, CallExpr): |
| 3336 | # * type variable definition |
| 3337 | if self.process_typevar_declaration(s): |
| 3338 | special_form = True |
| 3339 | elif self.process_paramspec_declaration(s): |
| 3340 | special_form = True |
| 3341 | elif self.process_typevartuple_declaration(s): |
| 3342 | special_form = True |
| 3343 | # * type constructors |
| 3344 | elif self.analyze_namedtuple_assign(s): |
| 3345 | special_form = True |
| 3346 | elif self.analyze_typeddict_assign(s): |
nothing calls this directly
no test coverage detected