nebius/SWE-bench-extra huggingface dataset:
Repository: numpy/numpydoc

Issue:
Failed See Also Parsing.
```
In [1]: from numpydoc.docscrape import NumpyDocString
   ...: from numpy import seterrobj
   ...: NumpyDocString("""seterrobj(errobj)
   ...:
   ...:     Set the object that defines floating-point error handling.
   ...:
   ...:     See Also
   ...:     --------
   ...:     geterrobj, seterr, geterr, seterrcall, geterrcall
   ...:     getbufsize, setbufsize""")['See Also']
Out[1]: []

In [2]:
```

```
diff --git a/numpydoc/docscrape.py b/numpydoc/docscrape.py
index 77de401..d79992c 100644
--- a/numpydoc/docscrape.py
+++ b/numpydoc/docscrape.py
@@ -284,6 +284,8 @@ class NumpyDocString(Mapping):

         """

+        content = dedent_lines(content)
         items = []

         def parse_item_name(text):
```

Might be enough, but it may also be the wrong place to put that:

```
In [1]: from numpydoc.docscrape import NumpyDocString
   ...: from numpy import seterrobj
   ...: NumpyDocString("""seterrobj(errobj)
   ...:
   ...:     Set the object that defines floating-point error handling.
   ...:
   ...:     See Also
   ...:     --------
   ...:     geterrobj, seterr, geterr, seterrcall, geterrcall
   ...:     getbufsize, setbufsize""")['See Also']
Out[1]:
[([('geterrobj', None),
   ('seterr', None),
   ('geterr', None),
   ('seterrcall', None),
   ('geterrcall', None)],
  []),
 ([('getbufsize', None), ('setbufsize', None)], [])]
```




Comments:

Patch:
diff --git a/numpydoc/docscrape.py b/numpydoc/docscrape.py
index 77de401..d79992c 100644
--- a/numpydoc/docscrape.py
+++ b/numpydoc/docscrape.py
@@ -284,6 +284,8 @@ class NumpyDocString(Mapping):
 
         """
 
+        content = dedent_lines(content)
+
         items = []
 
         def parse_item_name(text):


Test patch:
diff --git a/numpydoc/tests/test_docscrape.py b/numpydoc/tests/test_docscrape.py
index 8b29704..2ab0218 100644
--- a/numpydoc/tests/test_docscrape.py
+++ b/numpydoc/tests/test_docscrape.py
@@ -17,6 +17,7 @@ from numpydoc.docscrape import (
 )
 from numpydoc.docscrape_sphinx import (SphinxDocString, SphinxClassDoc,
                                        SphinxFunctionDoc, get_doc_object)
+import pytest
 from pytest import raises as assert_raises
 from pytest import warns as assert_warns
 
@@ -766,11 +767,16 @@ def test_warns():
     assert param.type == 'SomeWarning'
     assert param.desc == ['If needed']
 
-
-def test_see_also():
+# see numpydoc/numpydoc #281
+# we want to correctly parse "See Also" both in docstrings both like
+#"""foo
+# and
+#"""
+#foo
+@pytest.mark.parametrize('prefix', ['', '\n    '])
+def test_see_also(prefix):
     doc6 = NumpyDocString(
-    """
-    z(x,theta)
+    prefix + """z(x,theta)
 
     See Also
     --------
Repository: numpy/numpydoc

Issue:
How to specify that parameter can equal the string 'integer'?
Say I have the following:
```python
def foo(bar: str) -> None:
    """
    Parameters
    ----------
    bar : {'integer', 'float'}
        Some description.
    """
    if bar not in {'integer', 'float'}:
        raise ValueError('bar is neither "integer" nor "float"')
```

The parameter `bar` is a `str`, and can only take on the values `'integer'` and `'float'`. However, if I run `numpydoc` on it, it reports:
```console
$ python -m numpydoc t.foo --validate
t.foo:SS01:No summary found (a short summary in a single line should be present at the beginning of the docstring)
t.foo:ES01:No extended summary found
t.foo:PR06:Parameter "bar" type should use "int" instead of "integer"
t.foo:SA01:See Also section not found
t.foo:EX01:No examples section found
```
The first 2 and last 2 errors are expected, but the middle one (`PR06`) feels like a false positive.

Noticed when trying to validate `pandas.to_numeric` (https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.to_numeric.html), which has a parameter `downcast` which can be equal to the string `'integer'`

Comments:

Patch:
diff --git a/numpydoc/validate.py b/numpydoc/validate.py
index 91aca6b..3675737 100644
--- a/numpydoc/validate.py
+++ b/numpydoc/validate.py
@@ -564,6 +564,10 @@ def validate(obj_name):
             else:
                 if doc.parameter_type(param)[-1] == ".":
                     errs.append(error("PR05", param_name=param))
+                # skip common_type_error checks when the param type is a set of
+                # options
+                if "{" in doc.parameter_type(param):
+                    continue
                 common_type_errors = [
                     ("integer", "int"),
                     ("boolean", "bool"),


Test patch:
diff --git a/numpydoc/tests/test_validate.py b/numpydoc/tests/test_validate.py
index ecbe703..60cebcd 100644
--- a/numpydoc/tests/test_validate.py
+++ b/numpydoc/tests/test_validate.py
@@ -458,6 +458,28 @@ class GoodDocStrings:
         """
         pass
 
+    def valid_options_in_parameter_description_sets(self, bar):
+        """
+        Ensure a PR06 error is not raised when type is member of a set.
+
+        Literal keywords like 'integer' are valid when specified in a set of
+        valid options for a keyword parameter.
+
+        Parameters
+        ----------
+        bar : {'integer', 'boolean'}
+            The literal values of 'integer' and 'boolean' are part of an
+            options set and thus should not be subject to PR06 warnings.
+
+        See Also
+        --------
+        related : Something related.
+
+        Examples
+        --------
+        >>> result = 1 + 1
+        """
+
 
 class BadGenericDocStrings:
     """Everything here has a bad docstring
@@ -1089,6 +1111,7 @@ class TestValidator:
             "multiple_variables_on_one_line",
             "other_parameters",
             "warnings",
+            "valid_options_in_parameter_description_sets",
         ],
     )
     def test_good_functions(self, capsys, func):
Repository: numpy/numpydoc

Issue:
Parsing `returns` section with several types and no name
According to numpydoc [return value specification](https://numpydoc.readthedocs.io/en/latest/format.html#returns), the name for each return value may be optional. If the return value is omitted and the return type can take several types (if the actual type depends on user input, for example), then if the second type contains `" :"` as part of the type description (as in the following example) it is incorrectly identified as parameter type separator. This prevents sphinx recognition of the referenced type. 

```python
from numpydoc.docscrape import NumpyDocString
docstr="""
Returns
-------
str or :class:`NumpyDocString`
"""
print(NumpyDocString(docstr))
```
Results with:
```



Returns
-------
str or : class:`NumpyDocString`

```

I would expect getting the following result:
```



Returns
-------
str or :class:`NumpyDocString`

```

The example is using version 1.4.0.
I think this was changed in #286 .

Thanks!

Comments:

Patch:
diff --git a/numpydoc/docscrape.py b/numpydoc/docscrape.py
index 6bdaa84..9496f9d 100644
--- a/numpydoc/docscrape.py
+++ b/numpydoc/docscrape.py
@@ -226,10 +226,14 @@ class NumpyDocString(Mapping):
         params = []
         while not r.eof():
             header = r.read().strip()
-            if " :" in header:
-                arg_name, arg_type = header.split(" :", maxsplit=1)
-                arg_name, arg_type = arg_name.strip(), arg_type.strip()
+            if " : " in header:
+                arg_name, arg_type = header.split(" : ", maxsplit=1)
             else:
+                # NOTE: param line with single element should never have a
+                # a " :" before the description line, so this should probably
+                # warn.
+                if header.endswith(" :"):
+                    header = header[:-2]
                 if single_element_is_type:
                     arg_name, arg_type = "", header
                 else:


Test patch:
diff --git a/numpydoc/tests/test_docscrape.py b/numpydoc/tests/test_docscrape.py
index 55ccf92..049d2a2 100644
--- a/numpydoc/tests/test_docscrape.py
+++ b/numpydoc/tests/test_docscrape.py
@@ -980,6 +980,21 @@ doc8 = NumpyDocString(
 )
 
 
+def test_returns_with_roles_no_names():
+    """Make sure colons that are part of sphinx roles are not misinterpreted
+    as type separator in returns section. See gh-428."""
+    docstring = NumpyDocString(
+        """
+        Returns
+        -------
+        str or :class:`NumpyDocString`
+        """
+    )
+    expected = "str or :class:`NumpyDocString`"  # not "str or : class:...
+    assert docstring["Returns"][0].type == expected
+    assert expected in str(docstring)
+
+
 def test_trailing_colon():
     assert doc8["Parameters"][0].name == "data"