Northy1717/SWE-bench-Live huggingface dataset:
Repository: python/mypy

Issue:
[1.16 makes more common] Inference of Any against optional type infers Never
See the following example:

```
from typing import Any, Optional, TypeVar

T = TypeVar("T")


def assert_not_none(value: Optional[T]) -> T:
    assert value is not None
    return value


def foo1(a: Optional[Any]) -> int:
    return assert_not_none(a)[3]


def foo2(a: Optional[Any]) -> int:
    assert a is not None
    return a[3]

```

I would expect that `foo1` and `foo2` are equivalent. However, running `mypy` on this file, I get:

`test.py:12: error: Value of type <nothing> is not indexable`

For some reason, `assert_not_none` doesn't map `Optional[Any]` to `Any`, as it is supposed to (and which would accept the indexing), but instead maps it to `<nothing>` which throws an error. The second version with asserting that it is not None seems to work fine, though.


Discussion:
Definitely a bug and a somewhat surprising one too. Probably an issue in constraints.py?
The root cause is:
```python
a: Any
def assert_not_none(value: Optional[T]) -> T: ...
reveal_type(assert_not_none(a))  # Revealed type is "Never"
```
(and same with `Optional[Any]`) because of loose handling of unions in `constraints.py`. This is pretty bad IMO, so raising priority to high.
I encountered this when preparing an internal codebase for the 1.16 release. The issue wasn't directly related to any change in 1.16, though -- some additional `Any | None` types are inferred after recent changes.



Patch:
diff --git a/mypy/constraints.py b/mypy/constraints.py
index 8e7a30e05ffb..b1f3a8b180e1 100644
--- a/mypy/constraints.py
+++ b/mypy/constraints.py
@@ -416,7 +416,7 @@ def _infer_constraints(
                 infer_constraints_if_possible(t_item, actual, direction)
                 for t_item in template.items
             ],
-            eager=False,
+            eager=isinstance(actual, AnyType),
         )
         if result:
             return result


Test patch:
diff --git a/test-data/unit/check-inference.test b/test-data/unit/check-inference.test
index 381f73ed9862..4ae5ddb00b18 100644
--- a/test-data/unit/check-inference.test
+++ b/test-data/unit/check-inference.test
@@ -4071,3 +4071,13 @@ def check_or_nested(maybe: bool) -> None:
         reveal_type(foo)  # N: Revealed type is "builtins.list[builtins.int]"
         reveal_type(bar)  # N: Revealed type is "builtins.list[builtins.int]"
         reveal_type(baz)  # N: Revealed type is "builtins.list[builtins.int]"
+
+[case testInferOptionalAgainstAny]
+from typing import Any, Optional, TypeVar
+
+a: Any
+oa: Optional[Any]
+T = TypeVar("T")
+def f(x: Optional[T]) -> T: ...
+reveal_type(f(a))  # N: Revealed type is "Any"
+reveal_type(f(oa))  # N: Revealed type is "Any"
Repository: pyinfra-dev/pyinfra

Issue:
Fact `systemd.SystemdStatus` returns `False` for mounted `.mount` units
## Describe the bug
When querying the state of a [mount unit](https://www.freedesktop.org/software/systemd/man/latest/systemd.mount.html), the `SystemdStatus` fact runs a command like `systemctl show --all --property Id --property SubState mnt-foo.mount`. systemd will return `SubState=mounted` for mount units that are currently successfully mounted. (If they're unmounted, it will return `dead` instead.)

However, the fact will always return `False` for them. This is probably because `mounted` is not a member of [the `state_values` list](https://github.com/pyinfra-dev/pyinfra/blob/eb92851167ff7a8089a485ee5a44b48850fe5f0b/pyinfra/facts/systemd.py#L67) and thus treated as `False`.

This also means that an operation like

```python
systemd.service(
    service="mnt-foo.mount",
    enabled=True,
)
```

will _always_ be listed as a change, since pyinfra thinks the unit isn't active.

## To Reproduce
```console
$ pyinfra INVENTORY fact systemd.SystemdStatus services='*.mount'
```

## Expected behavior
Mounted mount units should have a return value of `True`.

## Meta

```console
$ uv run pyinfra --support
[…]
    System: Linux
      Platform: Linux-6.1.0-33-amd64-x86_64-with-glibc2.36
      Release: 6.1.0-33-amd64
      Machine: x86_64
    pyinfra: v3.3.1
      click: v8.2.1
      distro: v1.9.0
      gevent: v25.5.1
      jinja2: v3.1.6
      packaging: v25.0
      paramiko: v3.5.1
      python-dateutil: v2.9.0.post0
      pywinrm: v0.5.0
      pyyaml: v6.0.2
      pyyaml: v6.0.2
      setuptools: v80.9.0
      typeguard: v4.4.2
      typing-extensions: v4.13.2
    Executable: /home/**REDACTED**/.venv/bin/pyinfra
    Python: 3.13.1 (CPython, Clang 18.1.8 )
```


Discussion:

Patch:
diff --git a/pyinfra/facts/systemd.py b/pyinfra/facts/systemd.py
index c9a16581a..da42863a1 100644
--- a/pyinfra/facts/systemd.py
+++ b/pyinfra/facts/systemd.py
@@ -64,7 +64,7 @@ def requires_command(self, *args, **kwargs) -> str:
     default = dict
 
     state_key = "SubState"
-    state_values = ["running", "waiting", "exited", "listening"]
+    state_values = ["running", "waiting", "exited", "listening", "mounted"]
 
     @override
     def command(


Test patch:
diff --git a/tests/facts/systemd.SystemdStatus/services.json b/tests/facts/systemd.SystemdStatus/services.json
index c997a3b6e..d68abb2e1 100644
--- a/tests/facts/systemd.SystemdStatus/services.json
+++ b/tests/facts/systemd.SystemdStatus/services.json
@@ -12,12 +12,16 @@
         "SubState=dead",
         "",
         "Id=ebtables.timer",
-        "SubState=exited"
+        "SubState=exited",
+        "",
+        "Id=mnt-foo.mount",
+        "SubState=mounted"
     ],
     "fact":  {
         "lvm2-activation.service": false,
         "lvm2-lvmetad.service": true,
         "lvm2-lvmpolld.service": false,
-        "ebtables.timer": true
+        "ebtables.timer": true,
+        "mnt-foo.mount": true
     }
 }
Repository: jlowin/fastmcp

Issue:
Deprecation warning for passing `stateless_http` or `json_response` to FastMCP without replacement
### Description

As soon as one of the server settings parameter is passed the following warning is shown:

> Passing runtime and transport-specific settings as kwargs to the FastMCP constructor is deprecated (as of 2.3.4), including most transport settings. If possible, provide settings when calling run() instead.

However, there doesn't seem to be a replacement for those parameters for the `run` method.

### Example Code

```Python
from fastmcp import FastMCP

mcp = FastMCP(name='My MCP Server', stateless_http=True, json_response=True)

mcp.run(transport='streamable-http', port=8000)

# This wouldn't work:
# mcp.run(transport='streamable-http', port=8000, stateless_http=True, json_response=True)
```

### Version Information

```Text
fastmcp Version: v2.5.2

(I don't have the fastmcp cli)
```

### Additional Context

_No response_


Discussion:
Good point, this deprecation warning is more about intent. I'll update the message



Patch:
diff --git a/src/fastmcp/server/server.py b/src/fastmcp/server/server.py
index ca135a46..3d33595e 100644
--- a/src/fastmcp/server/server.py
+++ b/src/fastmcp/server/server.py
@@ -131,16 +131,6 @@ def __init__(
         tools: list[Tool | Callable[..., Any]] | None = None,
         **settings: Any,
     ):
-        if settings:
-            # TODO: remove settings. Deprecated since 2.3.4
-            warnings.warn(
-                "Passing runtime and transport-specific settings as kwargs "
-                "to the FastMCP constructor is deprecated (as of 2.3.4), "
-                "including most transport settings. If possible, provide settings when calling "
-                "run() instead.",
-                DeprecationWarning,
-                stacklevel=2,
-            )
         self.settings = fastmcp.settings.ServerSettings(**settings)
 
         # If mask_error_details is provided, override the settings value


Test patch:
diff --git a/tests/deprecated/test_deprecated.py b/tests/deprecated/test_deprecated.py
index f9facd65..e3de65bc 100644
--- a/tests/deprecated/test_deprecated.py
+++ b/tests/deprecated/test_deprecated.py
@@ -9,17 +9,6 @@
 from fastmcp import Client, FastMCP
 
 
-def test_fastmcp_kwargs_settings_deprecation_warning():
-    """Test that passing settings as kwargs to FastMCP raises a deprecation warning."""
-    with pytest.warns(
-        DeprecationWarning,
-        match="Passing runtime and transport-specific settings as kwargs to the FastMCP constructor is deprecated",
-    ):
-        server = FastMCP("TestServer", host="127.0.0.2", port=8001)
-        assert server.settings.host == "127.0.0.2"
-        assert server.settings.port == 8001
-
-
 def test_sse_app_deprecation_warning():
     """Test that sse_app raises a deprecation warning."""
     server = FastMCP("TestServer")
Repository: networkx/networkx

Issue:
Improve error message for removed `random_tree` function in NetworkX ≥ 3.4
### Summary

In NetworkX versions < 3.4, the function `networkx.random_tree` was available and widely used for generating random trees. From version 3.4 onward, this function has been **removed**, as per PRs [#7415](https://github.com/networkx/networkx/pull/7415) and [#7411](https://github.com/networkx/networkx/pull/7411).

However, trying to access it now results in a generic and confusing error:

```
AttributeError: module 'networkx' has no attribute 'random_tree'
```

This error message is **not informative**, especially for users upgrading from older code or referencing existing tutorials or notebooks.

---

### Suggestion

I propose adding a small `__getattr__` fallback in `networkx/__init__.py` to raise a clearer message when someone tries to access the removed function.

Example:

```python
def __getattr__(name):
    if name == "random_tree":
        raise AttributeError(
            "`networkx.random_tree` was removed in version 3.4. Use `networkx.random_labeled_tree` instead.\n"
            "See: https://networkx.org/documentation/networkx-3.5/release/release_3.4.html"
        )
    raise AttributeError(f"module 'networkx' has no attribute '{name}'")
```

This change would significantly improve developer experience when debugging legacy code or migrating projects from older versions.

Please let me know if you're open to this. I'm happy to open a PR for this right after!


Discussion:
Thank you very much for raising @supreethmv , this type of user feedback is invaluable!

Using the module __getattr__ to provide better exception messages for removed (i.e. post-deprecation) functionality is something I've long thought might be a good idea. +1 from me for doing so!



Patch:
diff --git a/networkx/__init__.py b/networkx/__init__.py
index de987ca0626..01256683119 100644
--- a/networkx/__init__.py
+++ b/networkx/__init__.py
@@ -51,3 +51,12 @@
 
 from networkx import drawing
 from networkx.drawing import *
+
+
+def __getattr__(name):
+    if name == "random_tree":
+        raise AttributeError(
+            "nx.random_tree was removed in version 3.4. Use `nx.random_labeled_tree` instead.\n"
+            "See: https://networkx.org/documentation/latest/release/release_3.4.html"
+        )
+    raise AttributeError(f"module 'networkx' has no attribute '{name}'")


Test patch:
diff --git a/networkx/tests/test_removed_functions_exception_messages.py b/networkx/tests/test_removed_functions_exception_messages.py
new file mode 100644
index 00000000000..47463456276
--- /dev/null
+++ b/networkx/tests/test_removed_functions_exception_messages.py
@@ -0,0 +1,8 @@
+import pytest
+
+import networkx as nx
+
+
+def test_random_tree():
+    with pytest.raises(AttributeError, match=".*Use `nx.random_labeled_tree` instead"):
+        nx.random_tree(3)