Skip to content

Commit

Permalink
Add Python 3.13 support
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshalX committed Oct 24, 2024
1 parent e5b1364 commit 96e0de2
Show file tree
Hide file tree
Showing 12 changed files with 214 additions and 196 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codegen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- name: Setup Poetry.
uses: snok/install-poetry@v1
with:
version: 1.5.1
version: 1.8.3

- name: Install dependencies.
run: poetry install --no-interaction
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Setup Poetry.
uses: snok/install-poetry@v1
with:
version: 1.5.1
version: 1.8.3

- name: Install Poetry Plugin.
run: poetry self add "poetry-dynamic-versioning[plugin]"
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ jobs:
python-version: 3.8

- name: Run linter check.
uses: chartboost/ruff-action@v1
uses: astral-sh/ruff-action@v1
with:
version: 0.1.2
version: 0.7.0

- name: Run code style check.
uses: chartboost/ruff-action@v1
uses: astral-sh/ruff-action@v1
with:
version: 0.1.2
args: format --check
version: 0.7.0
args: "format --check"
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
os: [ macos-latest, ubuntu-latest, windows-latest ]
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ]

runs-on: ${{matrix.os}}

Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Setup Poetry.
uses: snok/install-poetry@v1
with:
version: 1.5.1
version: 1.8.3

- name: Install dependencies.
run: poetry install --without docs
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update_lexicons.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Setup Poetry.
uses: snok/install-poetry@v1
with:
version: 1.5.1
version: 1.8.3

- name: Install dependencies.
run: poetry install --no-interaction
Expand Down
2 changes: 1 addition & 1 deletion packages/atproto_client/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _handle_kwagrs(kwargs: dict) -> None:
if content_type == _CONTENT_TYPE_JSON and 'data' in kwargs and kwargs['data']:
kwargs['data'] = get_model_as_json(kwargs['data'])

if 'params' in kwargs and kwargs['params']:
if kwargs.get('params'):
kwargs['params'] = get_model_as_dict(kwargs['params'])

# pop non-request kwargs
Expand Down
2 changes: 1 addition & 1 deletion packages/atproto_client/models/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def get_or_create(
raise ModelError(f"Can't properly parse model of type {model}")

return model_instance
except Exception as e: # noqa: BLE001
except Exception as e:
if strict or not isinstance(model_data, dict):
raise e

Expand Down
2 changes: 1 addition & 1 deletion packages/atproto_core/cbor/cbor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def decode_dag(data: bytes) -> dict:
"""
try:
return libipld.decode_dag_cbor(data)
except Exception as e: # noqa: BLE001
except Exception as e:
raise DAGCBORDecodingError from e


Expand Down
2 changes: 1 addition & 1 deletion packages/atproto_lexicon/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def lexicon_parse_file(lexicon_path: t.Union[Path, str], *, soft_fail: bool = Fa
with open(lexicon_path, encoding='UTF-8') as f:
plain_lexicon = from_json(f.read())
return lexicon_parse(plain_lexicon)
except Exception as e: # noqa: BLE001
except Exception as e:
if soft_fail:
return None

Expand Down
4 changes: 2 additions & 2 deletions packages/atproto_server/auth/jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def decode_jwt_payload(payload: t.Union[str, bytes]) -> JwtPayload:

try:
return JwtPayload(**plain_payload) # type: ignore # noqa: PGH003
except Exception as e: # noqa: BLE001
except Exception as e:
raise TokenDecodeError(f'Invalid payload string: {e}') from e


Expand Down Expand Up @@ -175,7 +175,7 @@ def validate_jwt_payload(payload: JwtPayload, leeway: int = 0) -> None:
def _verify_signature(signing_key: str, signing_input: bytes, signature: bytes) -> bool:
try:
return verify_signature(signing_key, signing_input, signature)
except Exception as e: # noqa: BLE001
except Exception as e:
raise TokenInvalidSignatureError('Could not verify JWT signature') from e


Expand Down
345 changes: 180 additions & 165 deletions poetry.lock

Large diffs are not rendered by default.

33 changes: 18 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "atproto"
version = "0.0.0" # placeholder. Dynamic version from Git Tag
version = "0.0.0" # This is a placeholder. Dynamic version from Git Tag will be used.
description = "The AT Protocol SDK"
authors = ["Ilya (Marshal) <[email protected]>"]
license = "MIT"
Expand All @@ -20,6 +20,7 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Software Development",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Pre-processors",
Expand Down Expand Up @@ -48,18 +49,18 @@ atp = "atproto_cli:atproto_cli"
atproto = "atproto_cli:atproto_cli"

[tool.poetry.dependencies]
python = ">=3.8,<3.13"
httpx = ">=0.25.0,<0.27.0"
python = ">=3.8,<3.14"
httpx = ">=0.25.0,<0.28.0"
typing-extensions = ">=4.8.0,<5"
click = ">=8.1.3,<9"
websockets = ">=12,<14"
pydantic = ">=2.7,<3"
libipld = ">=2.0.0,<3.0.0"
libipld = ">=2.0.0,<3"
dnspython = ">=2.4.0,<3"
cryptography = ">=41.0.7,<43"
cryptography = ">=41.0.7,<44"

[tool.poetry.group.dev.dependencies]
ruff = "0.1.2"
ruff = "0.7.0"
mypy = "1.9"
pyright = "1.1.362"

Expand Down Expand Up @@ -99,6 +100,13 @@ disallow_untyped_defs = false # TODO(MarshalX) enable
reportMissingTypeStubs = false

[tool.ruff]
line-length = 120
target-version = "py38"

[tool.ruff.format]
quote-style = "single"

[tool.ruff.lint]
extend-select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
Expand Down Expand Up @@ -129,20 +137,18 @@ extend-select = [
"TID",
"YTT",
]
line-length = 120
target-version = "py38"
ignore = [
"PGH004", # use specific rule code with noqa; works bad with JetBrains IDE Warnings
"ANN401", # t.Any in **kwargs
"ANN002", # Missing type annotation for `*args`
"ANN101", # Missing type annotation for `self` in method
"ANN102", # Missing type annotation for `cls` in classmethod
"D203", # we are not using blank line before class
"D213", # we are using first line for summary
"D203", "D413", # we are not using too many blank lines
"D213", # we are using the first line for summary
"D406", "D407", # we are using google style docstring
]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"packages/*.py" = [
"D105", "D104", "D100", "D107", "D103", "D415", # missing docstring
"D101", "D102", # missing docstring in public class and method
Expand All @@ -157,10 +163,7 @@ ignore = [
"packages/atproto_client/namespaces/sync_ns.py" = ["E501", "D401"]
"test.py" = ["S101", "ERA001", "T201", "E501", "F401", "D"]

[tool.ruff.flake8-quotes]
[tool.ruff.lint.flake8-quotes]
docstring-quotes = "double"
multiline-quotes = "double"
inline-quotes = "single"

[tool.ruff.format]
quote-style = "single"

0 comments on commit 96e0de2

Please sign in to comment.