Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into Akuli-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Akuli committed Feb 15, 2024
2 parents cbc2eb6 + 0b82c47 commit f3d4133
Show file tree
Hide file tree
Showing 14 changed files with 72 additions and 83 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ jobs:
import tomli
with open("pr/pyproject.toml", "rb") as f:
content = tomli.load(f)
for dep in content["project"]["dependencies"]:
print(dep)
for dep in content["project"]["optional-dependencies"]["dev"]:
print(dep)
' >> pr/requirements-dev.txt
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
python-version: "3.11"
cache: pip
- run: pip install wheel
- run: pip install -r requirements.txt -r requirements-dev.txt
- run: pip install -r requirements-dev.txt
- run: |
time mypy --platform linux --python-version 3.8 porcupine docs/extensions.py
time mypy --platform linux --python-version 3.9 porcupine docs/extensions.py
Expand All @@ -42,7 +42,7 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: pip
- run: pip install wheel
- run: pip install -r requirements.txt -r requirements-dev.txt
- run: pip install -r requirements-dev.txt
- if: matrix.os == 'ubuntu-latest'
# Make sure that it doesn't crash with Noto Color Emoji installed
run: sudo apt install --no-install-recommends fonts-noto-color-emoji tkdnd
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
- if: matrix.python-version != '3.8'
run: brew install python-tk@${{ matrix.python-version }}
- run: $PYTHON --version
- run: $PYTHON -m pip install -r requirements.txt -r requirements-dev.txt
- run: $PYTHON -m pip install -r requirements-dev.txt
- run: $PYTHON scripts/download-tkdnd.py
- run: $PYTHON -m pytest --durations=10

Expand Down
38 changes: 20 additions & 18 deletions .github/workflows/release-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
python-version: "3.8" # last version supporting windows 7
cache: pip
- run: pip install wheel
- run: pip install -r requirements.txt -r requirements-dev.txt
- run: pip install -r requirements-dev.txt
- uses: egor-tensin/setup-clang@v1
with:
platform: x64
Expand All @@ -25,22 +25,23 @@ jobs:
name: windows-exe
path: build/PorcupineSetup_*.exe

docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: pip
- run: pip install wheel
- run: pip install -r requirements.txt -r requirements-dev.txt
- run: python3 -m sphinx ./docs ./build
- if: startsWith(github.ref, 'refs/tags/v')
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: build
# TODO: enable docs again? don't know why broken
#docs:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - uses: actions/setup-python@v4
# with:
# python-version: "3.11"
# cache: pip
# - run: pip install wheel
# - run: pip install -r requirements-dev.txt
# - run: python3 -m sphinx ./docs ./build
# - if: startsWith(github.ref, 'refs/tags/v')
# uses: JamesIves/[email protected]
# with:
# branch: gh-pages
# folder: build

changelog:
runs-on: ubuntu-latest
Expand All @@ -58,7 +59,8 @@ jobs:
release:
runs-on: ubuntu-latest
# https://stackoverflow.com/a/58478262
needs: [windows-build, docs, changelog]
#needs: [windows-build, docs, changelog]
needs: [windows-build, changelog]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v2
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@ Unlike the Git commit history, this changelog does not include code cleanups
and other details that don't affect using Porcupine.


## v2024.02.07

Bug fixes:
- Porcupine no longer crashes on Mac when you try to open a file. Thank you [ThePhilgrim](https://github.com/ThePhilgrim) for fixing this.
- When the stop button (or other buttons) in the top right corner of the command output area are hovered, they display tooltips that explain what the buttons do. These tooltips no longer go partially off the screen when the Porcupine window is maximized or dragged to the right edge of the screen. Thank you [lawson89](https://github.com/lawson89) for fixing this.
- The directory tree now colors file names with non-ASCII characters correctly based on their Git status. For example, when a file is `git add`ed, it will now become green regardless of its file name. In previous versions, files named e.g. `örkkiäinen.txt` were always white.
- On some systems, such as Debian 12, the font chooser in Porcupine Settings now shows more fonts than before, and doesn't show a confusing warning triangle when the default font is selected.
- In previous versions, the "Jumping to previous/next anchor cycles to end/start of file" setting didn't work when the file contained only one anchor point. Thank you [ThePhilgrim](https://github.com/ThePhilgrim) for reporting this.

Other changes:
- Porcupine no longer runs on Python 3.7.
- Ctrl+Y does redo (that is, reverting a Ctrl+Z) also on Linux. Previously Linux users needed Ctrl+Shift+Z for redo.
- Ctrl+/ now comments selected lines, somewhat similarly to typing the filetype's comment character (e.g. `#` in a Python file).
- *Sort Lines* in the *Edit* menu now takes only the lines with the same indentation when nothing is selected. This is convenient for sorting long Python lists and dicts.
- Previously the encoding chooser was just a big list of encodings with no explanation. Now it's easy to choose between UTF-8 and Latin-1, and the encoding chooser explains their advantages and disadvantages.


## v2023.06.27

New features:
Expand Down
1 change: 0 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Then install Python 3.8 or newer and [git](https://git-scm.com/), and run these
cd porcupine
python3 -m venv env
source env/bin/activate
pip install -r requirements.txt
pip install -r requirements-dev.txt
python3 -m porcupine

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017-2023 Akuli
Copyright (c) 2017-2024 Akuli

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Open a terminal and run these commands:
python3 -m venv porcupine-venv
source porcupine-venv/bin/activate
pip install wheel
pip install https://github.com/Akuli/porcupine/archive/v2023.06.27.zip
pip install https://github.com/Akuli/porcupine/archive/v2024.02.07.zip
porcu

To easily run porcupine again later,
Expand All @@ -73,7 +73,7 @@ Then run these commands:
python3 -m venv porcupine-venv
source porcupine-venv/bin/activate
pip install wheel
pip install https://github.com/Akuli/porcupine/archive/v2023.06.27.zip
pip install https://github.com/Akuli/porcupine/archive/v2024.02.07.zip
porcu

To easily run porcupine again later,
Expand Down
4 changes: 2 additions & 2 deletions porcupine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

import platformdirs

version_info = (2023, 6, 27) # this is updated with scripts/release.py
version_info = (2024, 2, 7) # this is updated with scripts/release.py
__version__ = "%d.%02d.%02d" % version_info
__author__ = "Akuli"
__copyright__ = "Copyright (c) 2017-2023 Akuli"
__copyright__ = "Copyright (c) 2017-2024 Akuli"
__license__ = "MIT"

if sys.platform in {"win32", "darwin"}:
Expand Down
4 changes: 2 additions & 2 deletions porcupine/menubar.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def register_enabledness_check_event(event: str) -> None:
get_tab_manager().bind(event, _refresh_menu_item_enabledness, add=True)


def set_enabled_based_on_tab(path: str, callback: Callable[[tabs.Tab], bool]) -> None:
def set_enabled_based_on_tab(path: str, callback: Callable[[tabs.Tab | None], bool]) -> None:
"""Use this for disabling menu items depending on the currently selected tab.
When the selected :class:`~porcupine.tabs.Tab` changes, ``callback`` will
Expand Down Expand Up @@ -295,7 +295,7 @@ def update_enabledness(*junk: object, path: str) -> None:
index = _find_item(menu, child)
if index is None:
raise LookupError(f"menu item {path!r} not found")
if tab is not None and callback(tab):
if callback(tab):
menu.entryconfig(index, state="normal")
else:
menu.entryconfig(index, state="disabled")
Expand Down
8 changes: 4 additions & 4 deletions porcupine/plugins/filetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,14 @@ def parse_filetype_name(name: str) -> FileType:

def _sync_filetypes_menu(event: object = None) -> None:
tab = get_tab_manager().select()
filetype_name: str = ""
filetype_name: str | None = ""
if isinstance(tab, tabs.FileTab):
try:
filetype_name = tab.settings.get("filetype_name", str)
filetype_name = tab.settings.get("filetype_name", Optional[str])
except KeyError:
pass

filetypes_var.set(filetype_name)
filetypes_var.set(filetype_name or "")


def _add_filetype_menuitem(name: str, tk_var: tkinter.StringVar) -> None:
Expand Down Expand Up @@ -278,5 +278,5 @@ def setup() -> None:
new_file_filetypes = get_parsed_args().new_file or [] # argparse can give None
for filetype in new_file_filetypes:
tab = tabs.FileTab(get_tab_manager())
get_tab_manager().add_tab(tab) # sets default filetype
apply_filetype_to_tab(filetype, tab) # sets correct filetype
get_tab_manager().add_tab(tab)
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ build-backend = "flit_core.buildapi"

[project]
name = "porcupine"
version = "2023.06.27"
version = "2024.02.07"
description = "A decent editor written in tkinter"
authors = [{name = "Akuli", email = "[email protected]"}]
readme = "README.md"
Expand All @@ -41,7 +41,8 @@ dependencies = [
"psutil>=5.8.0,<6.0.0",
"PyYAML>=6.0,<7",
"tree-sitter-builds==2023.3.12",
"sv-ttk>=2.5.5",
# TODO: upgrade sv-ttk
"sv-ttk==2.5.5",
]

[project.optional-dependencies]
Expand Down
16 changes: 16 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
# Auto-generated in GitHub Actions. See autofix.yml.
platformdirs>=3.0.0,<4.0.0
Pygments==2.12.0
toposort>=1.5
colorama>=0.2.5
sansio-lsp-client>=0.10.0,<0.11.0
python-language-server[rope,pyflakes]>=0.36.2,<1.0.0
black>=21.5b2
isort>=5.10
typing_extensions
dacite>=1.5.1,<2.0.0
tomli==2.0.1
send2trash>=1.8.0,<2.0.0
psutil>=5.8.0,<6.0.0
PyYAML==6.0
tree-sitter-builds==2023.3.12
sv-ttk==2.5.5
pytest==6.2.5
pytest-cov==4.0.0
pytest-mock==3.10.0
Expand Down
20 changes: 0 additions & 20 deletions requirements.txt

This file was deleted.

28 changes: 0 additions & 28 deletions tests/test_porcupine_files.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import datetime
from pathlib import Path

import tomli

import porcupine


Expand All @@ -15,29 +13,3 @@ def test_license_file():

def test_copyright():
assert str(datetime.datetime.now().year) in porcupine.__copyright__


# The intended way to store dependency info is that setup.py or pyproject.toml contains version
# ranges, and requirements.txt contains specific versions in those ranges so that each deployment
# gets the same dependencies from there.
#
# A downside is that if your deployment also gets dependencies from other places, they could specify
# conflicting versions. This could be a problem for Porcupine: even though users usually install
# Porcupine into a virtualenv that doesn't contain anything else, I don't want to assume that they
# do.
#
# Another downside with pinning for Porcupine would be dependencies getting outdated easily.
#
# Solution: pin only the packages where updating will likely break things, and keep the same
# dependencies in requirements.txt (for easy "pip install -r requirements.txt" during development)
# and in pyproject.toml (for installing released versions).
def test_requirements_and_pyproject_toml_in_sync():
requirements = []
with open("requirements.txt") as file:
for line in file:
requirement = line.split("#")[0].strip()
if requirement:
requirements.append(requirement)

with open("pyproject.toml", "rb") as file:
assert tomli.load(file)["project"]["dependencies"] == requirements

0 comments on commit f3d4133

Please sign in to comment.