Skip to content

Commit

Permalink
Switch to python 3.8 (#2418)
Browse files Browse the repository at this point in the history
* "Add .python-version file"

* remove pathlib from dependencies

* change import

* Revert "change import" (:

This reverts commit c70cd57.

* Fix failing unittests on MacOS (#2436)

This commit adopts `unittesting.ViewTestCase` to run view related test cases.

ViewTestCase ...

1. provides `view` and `window` members pointing to a dedicated view, being
   created for testing.
2. ensures not to close empty windows, which was probably the most likely
   reason for unittests failing before on MacOS.

* keep the same order as before

* rchlint

* add release notes

* tweak release message

* Be more descriptive of what the user expect, or what the user can do if things go wrong

* tweak words

* fix typos

---------

Co-authored-by: Rafal Chlodnicki <[email protected]>
Co-authored-by: deathaxe <[email protected]>
Co-authored-by: Raoul Wols <[email protected]>
Co-authored-by: Predrag <[email protected]>
  • Loading branch information
5 people authored Apr 19, 2024
1 parent ec16d95 commit 1ea635c
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 32 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- if: ${{ matrix.os == 'macOS-latest' }}
run: brew unlink openssl
- uses: SublimeText/UnitTesting/actions/setup@v1
- uses: SublimeText/UnitTesting/actions/run-tests@v1
with:
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.8
1 change: 0 additions & 1 deletion dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
">=4096": [
"bracex",
"mdpopups",
"pathlib",
"wcmatch"
]
}
Expand Down
1 change: 1 addition & 0 deletions messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@
"1.7.0": "messages/1.7.0.txt",
"1.8.0": "messages/1.8.0.txt",
"1.9.0": "messages/1.9.0.txt",
"2.0.0": "messages/2.0.0.txt",
"install": "messages/install.txt"
}
32 changes: 32 additions & 0 deletions messages/2.0.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
=> 2.0.0

⚠️ Sublime Text will need to be restarted **more than once** for things to work properly. ⚠️

# Breaking changes

- LSP and LSP-* packages are transitioning from Python 3.3 to Python 3.8.

# FAQ

### What are the most significant improvements that stem from the 3.3 to 3.8 change?

There are no new features.
This is an internal LSP codebase change that affects all LSP-* packages.

### LSP is broken after the update even if Sublime Text is restarted many times

If that is the case, follow these steps:

- ##### Check if `"index_files"` is set to `false` in `Preferences.sublime-settings`

From the command palette open `Preferences: Settings` and see if `"index_files": false` exists.
If yes, remove that setting.

- ##### Check if `"LSP"` is put in `"ignored_packages"` in `Preferences.sublime-settings`

Ensure that LSP hasn't been added to the "ignored_packages" list during the update. If it has, remove it.

- ##### Reach for help

Feel free to [open an issue](https://github.com/sublimelsp/LSP/issues/new?assignees=&labels=&projects=&template=bug_report.md&title=) or reach out to us on [Discord](https://discord.gg/TZ5WN8t) if you encounter any problems during the update.
Please provide logs from the Sublime Text console.
51 changes: 22 additions & 29 deletions tests/test_configurations.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from LSP.plugin.core.configurations import WindowConfigManager
from test_mocks import DISABLED_CONFIG
from test_mocks import TEST_CONFIG
from unittest import TestCase
from unittest.mock import MagicMock
from unittesting import ViewTestCase
import sublime
import unittest


class GlobalConfigManagerTests(unittest.TestCase):
class GlobalConfigManagerTests(TestCase):

def test_empty_configs(self):
window_mgr = WindowConfigManager(sublime.active_window(), {})
Expand All @@ -24,35 +25,29 @@ def test_override_config(self):
self.assertFalse(list(window_mgr.all.values())[0].enabled)


class WindowConfigManagerTests(unittest.TestCase):
class WindowConfigManagerTests(ViewTestCase):

def test_no_configs(self):
view = sublime.active_window().active_view()
self.assertIsNotNone(view)
assert view
manager = WindowConfigManager(sublime.active_window(), {})
self.assertEqual(list(manager.match_view(view)), [])
self.assertIsNotNone(self.view)
self.assertIsNotNone(self.window)
manager = WindowConfigManager(self.window, {})
self.assertEqual(list(manager.match_view(self.view)), [])

def test_with_single_config(self):
window = sublime.active_window()
view = window.active_view()
self.assertIsNotNone(view)
assert view
manager = WindowConfigManager(window, {TEST_CONFIG.name: TEST_CONFIG})
view.syntax = MagicMock(return_value=sublime.Syntax(
self.assertIsNotNone(self.view)
self.assertIsNotNone(self.window)
manager = WindowConfigManager(self.window, {TEST_CONFIG.name: TEST_CONFIG})
self.view.syntax = MagicMock(return_value=sublime.Syntax(
path="Packages/Text/Plain text.tmLanguage",
name="Plain Text",
scope="text.plain",
hidden=False
))
view.settings().set("lsp_uri", "file:///foo/bar.txt")
self.assertEqual(list(manager.match_view(view)), [TEST_CONFIG])
self.view.settings().set("lsp_uri", "file:///foo/bar.txt")
self.assertEqual(list(manager.match_view(self.view)), [TEST_CONFIG])

def test_applies_project_settings(self):
window = sublime.active_window()
view = window.active_view()
assert view
window.project_data = MagicMock(return_value={
self.window.project_data = MagicMock(return_value={
"settings": {
"LSP": {
"test": {
Expand All @@ -61,24 +56,22 @@ def test_applies_project_settings(self):
}
}
})
manager = WindowConfigManager(window, {DISABLED_CONFIG.name: DISABLED_CONFIG})
view.syntax = MagicMock(return_value=sublime.Syntax(
manager = WindowConfigManager(self.window, {DISABLED_CONFIG.name: DISABLED_CONFIG})
self.view.syntax = MagicMock(return_value=sublime.Syntax(
path="Packages/Text/Plain text.tmLanguage",
name="Plain Text",
scope="text.plain",
hidden=False
))
view.settings().set("lsp_uri", "file:///foo/bar.txt")
configs = list(manager.match_view(view))
self.view.settings().set("lsp_uri", "file:///foo/bar.txt")
configs = list(manager.match_view(self.view))
self.assertEqual(len(configs), 1)
config = configs[0]
self.assertEqual(DISABLED_CONFIG.name, config.name)
self.assertTrue(config.enabled)

def test_disables_temporarily(self):
window = sublime.active_window()
view = window.active_view()
window.project_data = MagicMock(return_value={
self.window.project_data = MagicMock(return_value={
"settings": {
"LSP": {
"test": {
Expand All @@ -88,7 +81,7 @@ def test_disables_temporarily(self):
}
})

manager = WindowConfigManager(window, {DISABLED_CONFIG.name: DISABLED_CONFIG})
manager = WindowConfigManager(self.window, {DISABLED_CONFIG.name: DISABLED_CONFIG})
# disables config in-memory
manager.disable_config(DISABLED_CONFIG.name, only_for_session=True)
self.assertFalse(any(manager.match_view(view)))
self.assertFalse(any(manager.match_view(self.view)))

0 comments on commit 1ea635c

Please sign in to comment.