Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix linting issues reported by the latest version of Ruff #585

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pylsp/config/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ def _get_opt(cls, config, key, option, opt_type):
if not config.has_option(key, opt_key):
continue

if opt_type == bool:
if opt_type is bool:
return config.getboolean(key, opt_key)

if opt_type == int:
if opt_type is int:
return config.getint(key, opt_key)

if opt_type == str:
if opt_type is str:
return config.get(key, opt_key)

if opt_type == list:
if opt_type is list:
return cls._parse_list_opt(config.get(key, opt_key))

raise ValueError("Unknown option type: %s" % opt_type)
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import os
from io import StringIO
from test.test_utils import CALL_TIMEOUT_IN_SECONDS, ClientServerPair
from unittest.mock import MagicMock

import pytest
Expand All @@ -15,6 +14,7 @@
from pylsp.config.config import Config
from pylsp.python_lsp import PythonLSPServer
from pylsp.workspace import Document, Workspace
from test.test_utils import CALL_TIMEOUT_IN_SECONDS, ClientServerPair

DOC_URI = uris.from_fs_path(__file__)
DOC = """import sys
Expand Down
4 changes: 2 additions & 2 deletions test/plugins/test_autoimport.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Copyright 2022- Python Language Server Contributors.

from test.test_notebook_document import wait_for_condition
from test.test_utils import send_initialize_request, send_notebook_did_open
from typing import Any, Dict, List
from unittest.mock import Mock, patch

Expand All @@ -22,6 +20,8 @@
pylsp_completions as pylsp_autoimport_completions,
)
from pylsp.workspace import Workspace
from test.test_notebook_document import wait_for_condition
from test.test_utils import send_initialize_request, send_notebook_did_open

DOC_URI = uris.from_fs_path(__file__)

Expand Down
4 changes: 2 additions & 2 deletions test/test_configuration.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Copyright 2021- Python Language Server Contributors.

from test.test_notebook_document import wait_for_condition
from test.test_utils import send_initialize_request
from unittest.mock import patch

import pytest

from pylsp import IS_WIN
from test.test_notebook_document import wait_for_condition
from test.test_utils import send_initialize_request

INITIALIZATION_OPTIONS = {
"pylsp": {
Expand Down
3 changes: 1 addition & 2 deletions test/test_document.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Copyright 2017-2020 Palantir Technologies, Inc.
# Copyright 2021- Python Language Server Contributors.

from test.fixtures import DOC, DOC_URI

from pylsp.workspace import Document
from test.fixtures import DOC, DOC_URI


def test_document_props(doc):
Expand Down
3 changes: 2 additions & 1 deletion test/test_language_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
import os
import sys
import time
from test.test_utils import ClientServerPair, send_initialize_request

import pytest
from flaky import flaky
from pylsp_jsonrpc.exceptions import JsonRpcMethodNotFound

from test.test_utils import ClientServerPair, send_initialize_request

RUNNING_IN_CI = bool(os.environ.get("CI"))

CALL_TIMEOUT_IN_SECONDS = 10
Expand Down
10 changes: 5 additions & 5 deletions test/test_notebook_document.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Copyright 2021- Python Language Server Contributors.

import time
from test.test_utils import (
CALL_TIMEOUT_IN_SECONDS,
send_initialize_request,
send_notebook_did_open,
)
from unittest.mock import call, patch

import pytest

from pylsp import IS_WIN
from pylsp.lsp import NotebookCellKind
from pylsp.workspace import Notebook
from test.test_utils import (
CALL_TIMEOUT_IN_SECONDS,
send_initialize_request,
send_notebook_did_open,
)


def wait_for_condition(condition, timeout=CALL_TIMEOUT_IN_SECONDS):
Expand Down
3 changes: 1 addition & 2 deletions test/test_uris.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Copyright 2017-2020 Palantir Technologies, Inc.
# Copyright 2021- Python Language Server Contributors.

from test import unix_only, windows_only

import pytest

from pylsp import uris
from test import unix_only, windows_only


@unix_only
Expand Down
Loading