mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 21:05:08 +00:00
Respect mixed return
and raise
cases in return-type analysis (#9310)
## Summary Given: ```python from somewhere import get_cfg def lookup_cfg(cfg_description): cfg = get_cfg(cfg_description) if cfg is not None: return cfg raise AttributeError(f"No cfg found matching {cfg_description}") ``` We were analyzing the method from last-to-first statement. So we saw the `raise`, then assumed the method _always_ raised. In reality, though, it _might_ return. This PR improves the branch analysis to respect these mixed cases. Closes https://github.com/astral-sh/ruff/issues/9269. Closes https://github.com/astral-sh/ruff/issues/9304.
This commit is contained in:
parent
00f3c7d1d5
commit
2895e7d126
7 changed files with 482 additions and 203 deletions
|
@ -2,6 +2,7 @@ pub mod class;
|
|||
pub mod function_type;
|
||||
pub mod imports;
|
||||
pub mod logging;
|
||||
pub mod terminal;
|
||||
pub mod type_inference;
|
||||
pub mod typing;
|
||||
pub mod visibility;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue