Skip to content

Commit 47828d5

Browse files
committed
remove fire-and-forget methods | remove _async in methods name
1 parent 23ce2b7 commit 47828d5

File tree

9 files changed

+44
-27
lines changed

9 files changed

+44
-27
lines changed

.ci/patch_pubspec_version.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# /// script
2+
# dependencies = ["pyyaml"]
3+
# ///
4+
15
import os
26
import pathlib
37
import sys
@@ -17,7 +21,7 @@
1721
"flet",
1822
]
1923

20-
with open(pubspec_path, "r") as f:
24+
with open(pubspec_path) as f:
2125
data = yaml.safe_load(f)
2226

2327
# patch version

.ci/patch_toml_version.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# /// script
2+
# dependencies = ["tomlkit"]
3+
# ///
4+
15
import os
26
import pathlib
37
import sys
@@ -14,7 +18,7 @@
1418
print(f"Patching TOML file {toml_path} to {ver}")
1519

1620
# read
17-
with open(toml_path, "r") as f:
21+
with open(toml_path) as f:
1822
t = tomlkit.parse(f.read())
1923

2024
# patch version

.docstr.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
paths: src/flet_permission_handler
2+
badge: ./docs/assets/badges/docs-coverage.svg
3+
skip_file_doc: True
4+
skip_private: False
5+
ignore_patterns: # Dict with key/value pairs of file-pattern/node-pattern
6+
.*: __post_init__ # Ignore __post_init__ in all files
7+
fail_under: 50

appveyor.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,20 @@ image: ubuntu
33
version: '0.1.{build}'
44

55
environment:
6+
PYTHON_VERSION: 3.12
67
UV_PUBLISH_TOKEN:
78
secure: 174ncAbF5IjSIkmioPt62jeSnzmTlRNchUkE4QdjDWH8xK1olYtySXLJpo2q95HcP7lWJky1hv4APESiRRHnBWoY0XRFafzM/mbCDMzG1tZXiXZmpP1qzHAtRP2QSCIg18xh1TMktraUdTi7sbJnjjRhqzgbW1k0kLBxKw79MPFBhYQ/TiGcmaYWZbWVZNY3HCUCb6Dt7bG1OE2Ul9rD1gvs55xwO9Oq9FOVA1VnMYw=
89

9-
stack:
10-
- python 3.12
11-
1210
install:
1311
- source .ci/update_build_version.sh
14-
- python --version
15-
- python -m ensurepip --upgrade
16-
- pip3 install --upgrade tomlkit pyyaml
1712
- curl -LsSf https://astral.sh/uv/install.sh | sh
18-
- export PATH=$HOME/.local/bin:$PATH
13+
- export PATH="$HOME/.local/bin:$PATH"
14+
- uv python install $PYTHON_VERSION
15+
- uv python pin $PYTHON_VERSION
1916

2017
build_script:
21-
- python .ci/patch_toml_version.py pyproject.toml $PYPI_VER
22-
- python .ci/patch_pubspec_version.py src/flutter/flet_*/pubspec.yaml $PKG_VER
18+
- uv run .ci/patch_toml_version.py pyproject.toml $PYPI_VER
19+
- uv run .ci/patch_pubspec_version.py src/flutter/flet_*/pubspec.yaml $PKG_VER
2320
- (cd src/flutter/* && dart pub get && dart analyze && cd -)
2421
- uv build
2522

@@ -32,4 +29,4 @@ deploy_script:
3229
artifacts:
3330
- path: dist/*.whl
3431

35-
test: off
32+
test: off

examples/permission_handler_example/src/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ def show_snackbar(message: str):
1010
page.show_dialog(ft.SnackBar(ft.Text(message)))
1111

1212
async def get_permission_status(e: ft.Event[ft.OutlinedButton]):
13-
status = await p.get_status_async(fph.Permission.MICROPHONE)
13+
status = await p.get_status(fph.Permission.MICROPHONE)
1414
show_snackbar(f"Microphone permission status: {status.name}")
1515

1616
async def request_permission(e: ft.Event[ft.OutlinedButton]):
17-
status = await p.request_async(fph.Permission.MICROPHONE)
17+
status = await p.request(fph.Permission.MICROPHONE)
1818
show_snackbar(f"Requested microphone permission: {status.name}")
1919

2020
async def open_app_settings(e: ft.Event[ft.OutlinedButton]):
2121
show_snackbar("Opening app settings...")
22-
await p.open_app_settings_async()
22+
await p.open_app_settings()
2323

2424
p = fph.PermissionHandler()
2525
page.services.append(p) # (1)!

mkdocs.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ plugins:
109109
alias_type: symlink
110110
- glightbox
111111
- section-index
112+
- external-images:
113+
mappings:
114+
- source_dir: examples
115+
target_url_path: examples
116+
include_exts: [ ".png", ".gif", ".svg" ]
112117
- mkdocstrings:
113118
default_handler: python_xref
114119
handlers:
@@ -134,7 +139,6 @@ plugins:
134139
preload_modules: [ flet ]
135140
filters:
136141
- "!^_" # Exclude private members starting with only one underscore
137-
- "!get_event_field_type"
138142
extensions:
139143
- griffe_modernized_annotations
140144
- griffe_warnings_deprecated
@@ -185,3 +189,4 @@ markdown_extensions:
185189
- pymdownx.tasklist:
186190
custom_checkbox: true
187191
- pymdownx.tilde
192+
- pymdownx.blocks.caption

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,17 @@ docs = [
5454
"markdown-exec[ansi] >=1.11.0",
5555
"pydocstyle >=6.3.0",
5656
"linkcheckmd >=1.4.0",
57+
"mkdocs-external-images",
5758
{ include-group = 'docs-coverage' },
5859
]
5960
all = [
6061
{ include-group = 'dev' },
6162
{ include-group = 'docs' },
6263
]
6364

65+
[tool.uv.sources]
66+
mkdocs-external-images = { git = "https://github.com/flet-dev/mkdocs-external-images", tag = "v0.2.0" }
67+
6468
[build-system]
6569
requires = ["setuptools"]
6670
build-backend = "setuptools.build_meta"

src/flet_permission_handler/permission_handler.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def before_update(self):
4040
"Windows, and Web platforms."
4141
)
4242

43-
async def get_status_async(
43+
async def get_status(
4444
self, permission: Permission, timeout: int = 10
4545
) -> Optional[PermissionStatus]:
4646
"""
@@ -56,14 +56,14 @@ async def get_status_async(
5656
Raises:
5757
TimeoutError: If the request times out.
5858
"""
59-
status = await self._invoke_method_async(
59+
status = await self._invoke_method(
6060
method_name="get_status",
6161
arguments={"permission": permission},
6262
timeout=timeout,
6363
)
6464
return PermissionStatus(status) if status is not None else None
6565

66-
async def request_async(
66+
async def request(
6767
self, permission: Permission, timeout: int = 60
6868
) -> Optional[PermissionStatus]:
6969
"""
@@ -81,14 +81,14 @@ async def request_async(
8181
Raises:
8282
TimeoutError: If the request times out.
8383
"""
84-
r = await self._invoke_method_async(
84+
r = await self._invoke_method(
8585
method_name="request",
8686
arguments={"permission": permission},
8787
timeout=timeout,
8888
)
8989
return PermissionStatus(r) if r is not None else None
9090

91-
async def open_app_settings_async(self, timeout: int = 10) -> bool:
91+
async def open_app_settings(self, timeout: int = 10) -> bool:
9292
"""
9393
Opens the app settings page.
9494
@@ -101,7 +101,7 @@ async def open_app_settings_async(self, timeout: int = 10) -> bool:
101101
Raises:
102102
TimeoutError: If the request times out.
103103
"""
104-
return await self._invoke_method_async(
104+
return await self._invoke_method(
105105
method_name="open_app_settings",
106106
timeout=timeout,
107107
)

src/flutter/flet_permission_handler/lib/src/utils/permission_handler.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ Permission? parsePermission(String? value, [Permission? defaultValue]) {
55
if (value == null) return defaultValue;
66
return Permission.values.firstWhereOrNull(
77
(Permission p) =>
8-
p
9-
.toString()
10-
.split('.')
11-
.last
12-
.toLowerCase() == value.toLowerCase(),
8+
p.toString().split('.').last.toLowerCase() == value.toLowerCase(),
139
) ??
1410
defaultValue;
1511
}

0 commit comments

Comments
 (0)