nebius/SWE-bench-extra huggingface dataset:
Repository: pact-foundation/pact-python

Issue:
pact-verifier always results in an error when using pact broker with authentication
When I run:
```
pact-verifier --provider-base-url http://localhost:7599 --pact-urls https://my.pact.broker/pacts/provider/my-provider/consumer/my-consumer/latest --pact-broker-username username --pact-broker-password password
```

I always get:
```
ERROR: "pact-provider-verifier.rb verify" was called with arguments ["--pact-broker-username=username", "--pact-broker-password=password"]
Usage: "pact-provider-verifier.rb verify -h, --provider-base-url=PROVIDER_BASE_URL -u, --pact-urls=PACT_URLS"
```


Comments:

Patch:
diff --git a/pact/verify.py b/pact/verify.py
index ce33b2c..5add1fb 100644
--- a/pact/verify.py
+++ b/pact/verify.py
@@ -74,8 +74,8 @@ def main(base_url, pact_urls, states_url, states_setup_url, username,
         '--pact-urls': ','.join(pact_urls),
         '--provider-states-url': states_url,
         '--provider-states-setup-url': states_setup_url,
-        '--pact-broker-username': username,
-        '--pact-broker-password': password
+        '--broker-username': username,
+        '--broker-password': password
     }
 
     command = [VERIFIER_PATH] + [


Test patch:
diff --git a/pact/test/test_verify.py b/pact/test/test_verify.py
index b30c513..e540f15 100644
--- a/pact/test/test_verify.py
+++ b/pact/test/test_verify.py
@@ -113,7 +113,7 @@ class mainTestCase(TestCase):
         self.mock_Popen.return_value.returncode = 0
         result = self.runner.invoke(verify.main, self.default_opts)
         self.assertEqual(result.exit_code, 0)
-        self.assertProcess(*self.default_call + ['--pact-broker-password=pwd'])
+        self.assertProcess(*self.default_call + ['--broker-password=pwd'])
         self.mock_Popen.return_value.communicate.assert_called_once_with(
             timeout=30)
 
@@ -135,8 +135,8 @@ class mainTestCase(TestCase):
             '--pact-urls=./pacts/consumer-provider.json',
             '--provider-states-url=http=//localhost/provider-states',
             '--provider-states-setup-url=http://localhost/provider-states/set',
-            '--pact-broker-username=user',
-            '--pact-broker-password=pass')
+            '--broker-username=user',
+            '--broker-password=pass')
         self.mock_Popen.return_value.communicate.assert_called_once_with(
             timeout=60)
Repository: palantir/python-language-server

Issue:
TCP mode is not working since v0.15.0
When I attempt to start the language server in TCP mode using the command

``` pyls --tcp --host 127.0.0.1 --port 7003 ```

it fails to start the language server with the error ```Handler class must be an instance of PythonLanguageServer```

Comments:

Patch:
diff --git a/pyls/_utils.py b/pyls/_utils.py
index fb353c3..56a8630 100644
--- a/pyls/_utils.py
+++ b/pyls/_utils.py
@@ -104,5 +104,5 @@ def format_docstring(contents):
 def clip_column(column, lines, line_number):
     # Normalise the position as per the LSP that accepts character positions > line length
     # https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#position
-    max_column = len(lines[line_number]) - 1 if len(lines) > line_number else 0
+    max_column = len(lines[line_number].rstrip('\r\n')) if len(lines) > line_number else 0
     return min(column, max_column)
diff --git a/pyls/python_ls.py b/pyls/python_ls.py
index 61de356..e1c9297 100644
--- a/pyls/python_ls.py
+++ b/pyls/python_ls.py
@@ -32,7 +32,7 @@ class _StreamHandlerWrapper(socketserver.StreamRequestHandler, object):
 
 
 def start_tcp_lang_server(bind_addr, port, handler_class):
-    if not isinstance(handler_class, PythonLanguageServer):
+    if not issubclass(handler_class, PythonLanguageServer):
         raise ValueError('Handler class must be an instance of PythonLanguageServer')
 
     # Construct a custom wrapper class around the user's handler_class


Test patch:
diff --git a/test/test_utils.py b/test/test_utils.py
index 6675374..9d00686 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -52,6 +52,12 @@ def test_merge_dicts():
 
 
 def test_clip_column():
-    assert _utils.clip_column(5, ['123'], 0) == 2
-    assert _utils.clip_column(2, ['\n', '123'], 1) == 2
     assert _utils.clip_column(0, [], 0) == 0
+    assert _utils.clip_column(2, ['123'], 0) == 2
+    assert _utils.clip_column(3, ['123'], 0) == 3
+    assert _utils.clip_column(5, ['123'], 0) == 3
+    assert _utils.clip_column(0, ['\n', '123'], 0) == 0
+    assert _utils.clip_column(1, ['\n', '123'], 0) == 0
+    assert _utils.clip_column(2, ['123\n', '123'], 0) == 2
+    assert _utils.clip_column(3, ['123\n', '123'], 0) == 3
+    assert _utils.clip_column(4, ['123\n', '123'], 1) == 3
Repository: palantir/python-language-server

Issue:
No default source root
If no `setup.py` is found, `Workspace.source_roots()` currently returns `[]`.

I think a preferable alternative would be to return the Workspace root (as the language client may have other means for detecting a source root).

Comments:

Patch:
diff --git a/pyls/workspace.py b/pyls/workspace.py
index eaebc12..0ffab25 100644
--- a/pyls/workspace.py
+++ b/pyls/workspace.py
@@ -88,8 +88,8 @@ class Workspace(object):
 
     def source_roots(self, document_path):
         """Return the source roots for the given document."""
-        files = _utils.find_parents(self._root_path, document_path, ['setup.py']) or []
-        return [os.path.dirname(setup_py) for setup_py in files]
+        files = _utils.find_parents(self._root_path, document_path, ['setup.py', 'pyproject.toml']) or []
+        return list(set((os.path.dirname(project_file) for project_file in files))) or [self._root_path]
 
     def _create_document(self, doc_uri, source=None, version=None):
         path = uris.to_fs_path(doc_uri)


Test patch:
diff --git a/test/test_workspace.py b/test/test_workspace.py
index f510eaa..9b5b7b0 100644
--- a/test/test_workspace.py
+++ b/test/test_workspace.py
@@ -1,7 +1,9 @@
 # Copyright 2017 Palantir Technologies, Inc.
 import os
-import os.path as osp
 import sys
+
+import pytest
+
 from pyls import uris
 
 PY2 = sys.version_info.major == 2
@@ -16,7 +18,7 @@ DOC_URI = uris.from_fs_path(__file__)
 
 
 def path_as_uri(path):
-    return pathlib.Path(osp.abspath(path)).as_uri()
+    return pathlib.Path(os.path.abspath(path)).as_uri()
 
 
 def test_local(pyls):
@@ -49,14 +51,16 @@ def test_rm_document(pyls):
     assert pyls.workspace.get_document(DOC_URI)._source is None
 
 
-def test_non_root_project(pyls):
+@pytest.mark.parametrize('metafiles', [('setup.py',), ('pyproject.toml',), ('setup.py', 'pyproject.toml')])
+def test_non_root_project(pyls, metafiles):
     repo_root = os.path.join(pyls.workspace.root_path, 'repo-root')
     os.mkdir(repo_root)
     project_root = os.path.join(repo_root, 'project-root')
     os.mkdir(project_root)
 
-    with open(os.path.join(project_root, 'setup.py'), 'w+') as f:
-        f.write('# setup.py')
+    for metafile in metafiles:
+        with open(os.path.join(project_root, metafile), 'w+') as f:
+            f.write('# ' + metafile)
 
     test_uri = uris.from_fs_path(os.path.join(project_root, 'hello/test.py'))
     pyls.workspace.put_document(test_uri, 'assert True')
@@ -64,6 +68,15 @@ def test_non_root_project(pyls):
     assert project_root in test_doc.sys_path()
 
 
+def test_root_project_with_no_setup_py(pyls):
+    """Default to workspace root."""
+    workspace_root = pyls.workspace.root_path
+    test_uri = uris.from_fs_path(os.path.join(workspace_root, 'hello/test.py'))
+    pyls.workspace.put_document(test_uri, 'assert True')
+    test_doc = pyls.workspace.get_document(test_uri)
+    assert workspace_root in test_doc.sys_path()
+
+
 def test_multiple_workspaces(tmpdir, pyls):
     workspace1_dir = tmpdir.mkdir('workspace1')
     workspace2_dir = tmpdir.mkdir('workspace2')