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
18 changes: 14 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,22 @@ name: Python package
on: [push]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
python-version: 3.12
- name: Install dependencies
run: uv sync --dev
- name: Ruff checks
run: uv run ruff check .
- name: Ruff format check
run: uv run ruff format --check
build:
runs-on: ubuntu-latest
needs: lint
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
Expand All @@ -16,10 +30,6 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --dev
- name: Ruff checks
run: uv run ruff check .
- name: Ruff format check
run: uv run ruff format --check
- name: Pyright type check
# Don't fail on errors yet
run: uv run pyright filesender || true
Expand Down
11 changes: 11 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## Version 2.1.2

### Fixed

* `LogParam.get_metavar()` raised a `TypeError` with Click 8.2+ due to a new `ctx` parameter being added to `ParamType.get_metavar()`
* Fix for when the FileSender server has disabled CSRF tokens

### Changed

* Dev dependencies moved from `[project.optional-dependencies]` to `[tool.uv] dev-dependencies` so that `uv sync --dev` installs them correctly

## Version 2.1.1

### Changed
Expand Down
10 changes: 6 additions & 4 deletions filesender/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ class GuestAuth(Auth):

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

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

def sign(self, request: SignType, client: AsyncClient) -> SignType:
request.url = request.url.copy_add_param("vid", self.guest_token)
if self.security_token is None or self.csrf_token is None:
if self.security_token is None:
raise Exception(
".prepare() must be called on the GuestAuth before it is used to sign requests"
)
request.headers["X-Filesender-Security-Token"] = self.security_token
request.headers["csrfptoken"] = self.csrf_token
if self.csrf_token is not None:
# If we have a CSRF token, the server requires it so we should use it
request.headers["csrfptoken"] = self.csrf_token
return request
4 changes: 3 additions & 1 deletion filesender/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def convert(

return LogLevel[value].value

def get_metavar(self, param: Parameter) -> Union[str, None]:
def get_metavar(
self, param: Parameter, ctx: Union[Context, None]
) -> Union[str, None]:
# Print out the choices
return "|".join(LogLevel._member_map_)
35 changes: 16 additions & 19 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "filesender-client"
description = "FileSender Python CLI and API client"
version = "2.1.1"
version = "2.1.2"
readme = "README.md"
requires-python = ">=3.10"
license = {text = "BSD-3-Clause"}
Expand All @@ -26,14 +26,26 @@ dependencies = [
"typing_extensions",
"tenacity",
"tqdm",
"click>=8.1.8",
# Click 8.2 introduced a breaking change (https://click.palletsprojects.com/en/stable/support-multiple-versions/#paramtype-methods-require-ctx)
"click>=8.2",
]

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

[project.optional-dependencies]
[project.scripts]
filesender = "filesender.main:app"

[tool.pyright]
typeCheckingMode = "strict"
exclude = ["venv", "test"]
reportUnknownMemberType = false
reportUnknownVariableType = false

[dependency-groups]
dev = [
"pyright>=1.1.410",
"ruff>=0.15.15",
"pytest",
"pytest_asyncio",
"mkdocs",
Expand All @@ -49,20 +61,5 @@ dev = [
"jupyter",
"notebook<7",
"nbconvert",
"jupyter_contrib_nbextensions"
]

[project.scripts]
filesender = "filesender.main:app"

[tool.pyright]
typeCheckingMode = "strict"
exclude = ["venv", "test"]
reportUnknownMemberType = false
reportUnknownVariableType = false

[dependency-groups]
dev = [
"pyright>=1.1.410",
"ruff>=0.15.15",
"jupyter_contrib_nbextensions",
]
Loading
Loading