Skip to content
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
33 changes: 15 additions & 18 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
## Development environment

## Code Style

We use [Black](https://black.readthedocs.io/en/stable/) (PEP 8 compliant) for code formatting.
When developing Dialect it is encouraged to use the [uv](https://docs.astral.sh/uv/) project manager.

Install it to format your code after writing code or use it in your IDE as code formatter.
After installing uv, run `uv sync` to create or sync a venv with the projects dependencies.

To format run:
## Code Style

```sh
black dialect
```
We use the Ruff formatter (PEP 8 compliant) for code formatting.

We also use [isort](https://pycqa.github.io/isort/) for imports sorting.
To format the code run:

```sh
isort dialect
ruff check --select I --fix && ruff format
```

### Type Annotations
Expand All @@ -25,14 +22,14 @@ We try to use Python type annotations whenever is possible.

- Explicit classes instantiation like:

```python
var = Class()
```
```python
var = Class()
```

- Non-nullable argument with default value:

```python
# We omit `int` typing for `number`
def method(text: str, number = 5, other: int | None = 20):
...
```
```python
# We omit `int` typing for `number`
def method(text: str, number = 5, other: int | None = 20):
...
```
6 changes: 2 additions & 4 deletions build-aux/flatpak/app.drey.Dialect.Devel.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,16 @@
"--socket=pulseaudio",
"--own-name=app.drey.Dialect.Devel.SearchProvider"
],
"cleanup": [
"*blueprint*"
],
"modules": [
"pypi-dependencies.json",
{
"name": "blueprint",
"buildsystem": "meson",
"cleanup": ["*"],
"sources": [
{
"type": "git",
"url": "https://gitlab.gnome.org/jwestman/blueprint-compiler",
"url": "https://gitlab.gnome.org/GNOME/blueprint-compiler",
"branch": "main"
}
]
Expand Down
2 changes: 1 addition & 1 deletion dialect/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ def background_task(f: Callable[..., Coroutine]):
@functools.wraps(f)
def decor(*args, **kwargs):
app = Gio.Application.get_default()
app.create_asyncio_task(f(*args, **kwargs))
app.create_asyncio_task(f(*args, **kwargs)) # type: ignore

return decor
1 change: 1 addition & 0 deletions dialect/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from gi.repository import Adw, Gio, GLib, Gst
except ImportError or ValueError:
logging.error("Error: GObject dependencies not met.")
exit()

from dialect.define import APP_ID, RES_PATH, VERSION
from dialect.preferences import DialectPreferencesDialog
Expand Down
1 change: 0 additions & 1 deletion dialect/providers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ def cmp_langs(self, a: str, b: str) -> bool:

return False


def dest_langs_for(self, code: str) -> list[str]:
"""
Get the available destination languages for a source language.
Expand Down
2 changes: 1 addition & 1 deletion dialect/providers/soup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SoupProvider(BaseProvider):

def __init__(self, **kwargs):
super().__init__(**kwargs)

self.retry_errors: tuple[int] = tuple()
""" Error codes that should be retried automatically """
self.max_retries = 5
Expand Down
2 changes: 1 addition & 1 deletion dialect/widgets/textview.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def font_size(self, value: int):
# Save value
self._font_size = value
# Update CSS
self._font_css_provider.load_from_data(f"textview {{ font-size: { str(value) }pt; }}")
self._font_css_provider.load_from_data(f"textview {{ font-size: {str(value)}pt; }}")

def font_size_inc(self):
self.font_size += 5
Expand Down
17 changes: 15 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@

[project]
name = "Dialect"
version = "2.4.2"
version = "2.6.0"
requires-python = ">=3.10"
dependencies = [
"beautifulsoup4>=4.13.4",
"gtts>=2.5.4",
]

[tool.black]
line-length = 120
Expand All @@ -16,3 +19,13 @@ builtins = ["_", "gettext"]

[tool.pyright]
reportMissingModuleSource = false
reportIncompatibleMethodOverride = false
typeCheckingMode = "standard"
ignore = ['po/']

[dependency-groups]
dev = [
"basedpyright>=1.31.0",
"pygobject-stubs>=2.13.0",
"ruff>=0.12.5",
]
4 changes: 0 additions & 4 deletions requirements-dev.txt

This file was deleted.

15 changes: 13 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
gtts
beautifulsoup4
# This file was autogenerated by uv via the following command:
# uv export --no-emit-workspace --no-dev --no-annotate --no-hashes --output-file requirements.txt
beautifulsoup4==4.13.4
certifi==2025.7.14
charset-normalizer==3.4.2
click==8.1.8
colorama==0.4.6 ; sys_platform == 'win32'
gtts==2.5.4
idna==3.10
requests==2.32.4
soupsieve==2.7
typing-extensions==4.14.1
urllib3==2.5.0
259 changes: 259 additions & 0 deletions uv.lock

Large diffs are not rendered by default.