facebook / facebook/pyrefly

False positive in ipaddress._BaseNetwork.subnet_of

Open
#2,062 1 comment 0 reactions 0 assignees View on GitHub
needs-discussion
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

### Describe the Bug

```
import ipaddress

supernet = ipaddress.ip_network("10.10.1.0/24")
subnet = ipaddress.ip_network("10.10.1.32/28")
is_subnet = subnet.subnet_of(supernet) # error
```

`ip_network` returns `Ipv4network|Ipv6network`, while the overload of `is_subnet` requires self & other to be the same kind.

In theory it's possible that one of them is ipv4 and the other is ipv6, and we're behaving correctly here according to the type signatures (mypy and pyright do the same thing)

But this is in the standard library so I wonder if we can do better somehow

from https://youtrack.jetbrains.com/issue/PY-86719/Pyrefly-is-way-too-overzealous

### Sandbox Link

https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeSIEAtsbgE4AuABBMappnfHADrp9wArsRh10MZgF4WbDlzhxCrAPriGAd3oBrABQ8QARgAMhY6cJGA9ACYALPoCUAwdjVNprdp25LiqiZp0uvpmoYQAzNY2AByOfBBwykKuEu5MyWqEGRLKuGA6QiJiEg4gADQgZFxgUKSEDLhUUBQAxEwACqTVtekYOARMAMa46JAA5oJ0qAwQI4R8bQDKMDBMABYMDMRwiJaWVTA1dfRjljDolpi4g3CWw6MQE1MzI5ZMYPRMqABuqNCo2FgQxG40m01m6CYuGIL3Qij4ZAYaxGAFpvqI4BC0vpwqZrPo%2BCAAL4VVCDGbogBi0BgFDQWDwRDIxKAA

### (Only applicable for extension issues) IDE Information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.