Skip to content

Commit 958b82f

Browse files
authored
Merge pull request #41 from WEHI-ResearchComputing/3.1.2
June 2026 Maintenance
2 parents 9f8559c + 5dd7126 commit 958b82f

6 files changed

Lines changed: 3630 additions & 28 deletions

File tree

.github/workflows/build.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,22 @@ name: Python package
33
on: [push]
44

55
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
- uses: astral-sh/setup-uv@v5
11+
with:
12+
python-version: 3.12
13+
- name: Install dependencies
14+
run: uv sync --dev
15+
- name: Ruff checks
16+
run: uv run ruff check .
17+
- name: Ruff format check
18+
run: uv run ruff format --check
619
build:
720
runs-on: ubuntu-latest
21+
needs: lint
822
strategy:
923
matrix:
1024
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
@@ -16,10 +30,6 @@ jobs:
1630
python-version: ${{ matrix.python-version }}
1731
- name: Install dependencies
1832
run: uv sync --dev
19-
- name: Ruff checks
20-
run: uv run ruff check .
21-
- name: Ruff format check
22-
run: uv run ruff format --check
2333
- name: Pyright type check
2434
# Don't fail on errors yet
2535
run: uv run pyright filesender || true

docs/changelog.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog
22

3+
## Version 2.1.2
4+
5+
### Fixed
6+
7+
* `LogParam.get_metavar()` raised a `TypeError` with Click 8.2+ due to a new `ctx` parameter being added to `ParamType.get_metavar()`
8+
* Fix for when the FileSender server has disabled CSRF tokens
9+
10+
### Changed
11+
12+
* Dev dependencies moved from `[project.optional-dependencies]` to `[tool.uv] dev-dependencies` so that `uv sync --dev` installs them correctly
13+
314
## Version 2.1.1
415

516
### Changed

filesender/auth.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ class GuestAuth(Auth):
9595

9696
guest_token: str
9797
security_token: Optional[str] = None
98+
# The CSRF token is configurable per-server, so we need to store it if the server provides it, but it isn't mandatory
99+
# See https://github.com/filesender/filesender/issues/2732#issuecomment-4609996918
98100
csrf_token: Optional[str] = None
99101

100102
async def prepare(self, client: AsyncClient):
@@ -113,15 +115,15 @@ async def prepare(self, client: AsyncClient):
113115
for cookie in client.cookies.jar:
114116
if cookie.name.lower() == "csrfptoken":
115117
self.csrf_token = cookie.value
116-
if self.csrf_token is None:
117-
logger.warning("No CSRF token could be found!")
118118

119119
def sign(self, request: SignType, client: AsyncClient) -> SignType:
120120
request.url = request.url.copy_add_param("vid", self.guest_token)
121-
if self.security_token is None or self.csrf_token is None:
121+
if self.security_token is None:
122122
raise Exception(
123123
".prepare() must be called on the GuestAuth before it is used to sign requests"
124124
)
125125
request.headers["X-Filesender-Security-Token"] = self.security_token
126-
request.headers["csrfptoken"] = self.csrf_token
126+
if self.csrf_token is not None:
127+
# If we have a CSRF token, the server requires it so we should use it
128+
request.headers["csrfptoken"] = self.csrf_token
127129
return request

filesender/log.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ def convert(
4949

5050
return LogLevel[value].value
5151

52-
def get_metavar(self, param: Parameter) -> Union[str, None]:
52+
def get_metavar(
53+
self, param: Parameter, ctx: Union[Context, None]
54+
) -> Union[str, None]:
5355
# Print out the choices
5456
return "|".join(LogLevel._member_map_)

pyproject.toml

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
55
[project]
66
name = "filesender-client"
77
description = "FileSender Python CLI and API client"
8-
version = "2.1.1"
8+
version = "2.1.2"
99
readme = "README.md"
1010
requires-python = ">=3.10"
1111
license = {text = "BSD-3-Clause"}
@@ -26,14 +26,26 @@ dependencies = [
2626
"typing_extensions",
2727
"tenacity",
2828
"tqdm",
29-
"click>=8.1.8",
29+
# Click 8.2 introduced a breaking change (https://click.palletsprojects.com/en/stable/support-multiple-versions/#paramtype-methods-require-ctx)
30+
"click>=8.2",
3031
]
3132

3233
[tool.setuptools.packages.find]
3334
exclude = ["site", "test"]
3435

35-
[project.optional-dependencies]
36+
[project.scripts]
37+
filesender = "filesender.main:app"
38+
39+
[tool.pyright]
40+
typeCheckingMode = "strict"
41+
exclude = ["venv", "test"]
42+
reportUnknownMemberType = false
43+
reportUnknownVariableType = false
44+
45+
[dependency-groups]
3646
dev = [
47+
"pyright>=1.1.410",
48+
"ruff>=0.15.15",
3749
"pytest",
3850
"pytest_asyncio",
3951
"mkdocs",
@@ -49,20 +61,5 @@ dev = [
4961
"jupyter",
5062
"notebook<7",
5163
"nbconvert",
52-
"jupyter_contrib_nbextensions"
53-
]
54-
55-
[project.scripts]
56-
filesender = "filesender.main:app"
57-
58-
[tool.pyright]
59-
typeCheckingMode = "strict"
60-
exclude = ["venv", "test"]
61-
reportUnknownMemberType = false
62-
reportUnknownVariableType = false
63-
64-
[dependency-groups]
65-
dev = [
66-
"pyright>=1.1.410",
67-
"ruff>=0.15.15",
64+
"jupyter_contrib_nbextensions",
6865
]

0 commit comments

Comments
 (0)