diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e4c436ec..4c3854d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,11 +11,11 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.12'] + python-version: ['3.12', '3.13', '3.14', '3.15'] services: postgres: - image: postgres:14 + image: postgres:17 env: POSTGRES_HOST_AUTH_METHOD: trust ports: @@ -46,7 +46,7 @@ jobs: export PGPORT=${{ job.services.postgres.ports[5432] }} export PGUSER=postgres createuser newdletest - createdb newdle_tests + createdb -O newdletest newdle_tests - name: Activate virtualenv for later steps run: | diff --git a/newdle/api.py b/newdle/api.py index 80d40334..2b39c87f 100644 --- a/newdle/api.py +++ b/newdle/api.py @@ -206,7 +206,10 @@ def _match(user, name, email): @api.route('/users/') @use_kwargs( - {'name': fields.String(missing=None), 'email': fields.String(missing=None)}, + { + 'name': fields.String(load_default=None), + 'email': fields.String(load_default=None), + }, location='query', ) def users(name, email): diff --git a/newdle/models.py b/newdle/models.py index ab8a2292..5ffefc94 100644 --- a/newdle/models.py +++ b/newdle/models.py @@ -93,7 +93,7 @@ def update_lastmod(self): @property def available_timeslots(self): - """Get the list of timeslots for which no one has answered with 'available'.""" + """The list of timeslots for which no one has answered with 'available'.""" if not self.limited_slots: return self.timeslots diff --git a/newdle/newdle.cfg.example b/newdle/newdle.cfg.example index d6406bff..d1600f0e 100644 --- a/newdle/newdle.cfg.example +++ b/newdle/newdle.cfg.example @@ -48,7 +48,7 @@ NEWDLE_CODE_LENGTH = 8 # See the documentation of Flask-Caching for a list of available # cache types and their configuration options: # https://flask-caching.readthedocs.io/en/latest/#configuring-flask-caching -CACHE_TYPE = 'simple' +CACHE_TYPE = 'SimpleCache' # Specify how emails are sent. For production use, you need the `smtp` backend, diff --git a/newdle/providers/free_busy/exchange.py b/newdle/providers/free_busy/exchange.py index 839e56f9..9739d998 100644 --- a/newdle/providers/free_busy/exchange.py +++ b/newdle/providers/free_busy/exchange.py @@ -49,7 +49,7 @@ def refresh(self, session): # XXX i think we never get here since msal refreshes it and sessions # do not persist print('refresh called') - # self.access_token = ... + assert False, 'should not call refresh' def get_token_from_msal(): diff --git a/newdle/providers/free_busy/util.py b/newdle/providers/free_busy/util.py index 0e7fca4f..09c5c087 100644 --- a/newdle/providers/free_busy/util.py +++ b/newdle/providers/free_busy/util.py @@ -41,7 +41,6 @@ def get_msal_token(*, force=False): assert accounts[0]['username'] == username result = app.acquire_token_silent( scopes=[ - # 'https://outlook.office.com/Calendars.Read.Shared', 'https://outlook.office.com/EWS.AccessAsUser.All', ], account=accounts[0], diff --git a/newdle/schemas.py b/newdle/schemas.py index b0fc8bcf..dee1e53e 100644 --- a/newdle/schemas.py +++ b/newdle/schemas.py @@ -9,7 +9,6 @@ validates, validates_schema, ) -from marshmallow_enum import EnumField from pytz import common_timezones_set from newdle.core.marshmallow import mm @@ -52,7 +51,7 @@ def sign(self, data, many, **kwargs): {**data, 'auth_uid': data['uid']}, fields={'email', 'name', 'auth_uid'} ) - @post_dump(pass_many=True) + @post_dump(pass_collection=True) def sort_users(self, data, many, **kwargs): if many: data = sorted(data, key=lambda x: x['name'].lower()) @@ -121,8 +120,8 @@ class ParticipantSchema(mm.Schema): email = fields.String() auth_uid = fields.String() code = fields.String() - answers = fields.Mapping( - fields.DateTime(format=DATETIME_FORMAT), EnumField(Availability) + answers = fields.Dict( + fields.DateTime(format=DATETIME_FORMAT), fields.Enum(Availability) ) comment = fields.String() avatar_url = fields.Function( @@ -132,7 +131,7 @@ class ParticipantSchema(mm.Schema): ) @validates('name') - def name_not_empty(self, value): + def name_not_empty(self, value, data_key): if not value: raise ValidationError('This field cannot be empty.') @@ -149,10 +148,10 @@ def sign(self, data, many, **kwargs): class UpdateParticipantSchema(mm.Schema): - answers = fields.Mapping( - fields.DateTime(format=DATETIME_FORMAT), EnumField(Availability) + answers = fields.Dict( + fields.DateTime(format=DATETIME_FORMAT), fields.Enum(Availability) ) - comment = fields.String(default='') + comment = fields.String() class NewNewdleSchema(mm.Schema): @@ -172,13 +171,14 @@ class NewNewdleSchema(mm.Schema): ) limited_slots = fields.Boolean() participants = fields.List( - fields.Nested(NewKnownParticipantSchema, unknown=EXCLUDE), missing=[] + fields.Nested(NewKnownParticipantSchema, unknown=EXCLUDE), + load_default=lambda: [], ) private = fields.Boolean(required=True) notify = fields.Boolean(required=True) @validates('timeslots') - def validate_timeslots(self, v): + def validate_timeslots(self, v, data_key): if len(set(v)) != len(v): raise ValidationError('Time slots are not unique') diff --git a/pyproject.toml b/pyproject.toml index c5bb5149..7876445e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,6 +11,9 @@ classifiers = [ 'Framework :: Flask', 'License :: OSI Approved :: MIT License', 'Programming Language :: Python :: 3.12', + 'Programming Language :: Python :: 3.13', + 'Programming Language :: Python :: 3.14', + 'Programming Language :: Python :: 3.15', ] requires-python = '~=3.12' @@ -20,7 +23,7 @@ Issues = 'https://github.com/indico/newdle/issues' GitHub = 'https://github.com/indico/newdle' [build-system] -requires = ['hatchling==1.27.0', 'hatch-requirements-txt==0.4.1'] +requires = ['hatchling==1.32.4', 'hatch-requirements-txt==0.4.1'] build-backend = 'hatchling.build' [tool.hatch.metadata.hooks.requirements_txt] @@ -43,5 +46,6 @@ exclude = [ artifacts = ['newdle/client/build/'] [tool.uv] +exclude-newer = '1 week' # uv does not know about dynamic metadata so `pip install -e .` should always reinstall reinstall-package = ['newdle'] diff --git a/requirements.cern.txt b/requirements.cern.txt index 44a61d2c..a4143a88 100644 --- a/requirements.cern.txt +++ b/requirements.cern.txt @@ -1,45 +1,46 @@ # This file was autogenerated by uv via the following command: # uv pip compile requirements.cern.in -o requirements.cern.txt -authlib==1.3.0 +authlib==1.9.1 # via # -c requirements.txt # flask-multipass -blinker==1.8.2 +blinker==1.9.0 # via # -c requirements.txt # flask # flask-multipass -certifi==2024.2.2 +certifi==2026.10.19 # via # -c requirements.txt # requests -cffi==1.16.0 +cffi==2.1.1 # via # -c requirements.txt # cryptography -charset-normalizer==3.3.2 +charset-normalizer==3.5.2 # via # -c requirements.txt # requests -click==8.1.7 +click==8.5.0 # via # -c requirements.txt # flask -cryptography==42.0.7 +cryptography==50.0.2 # via # -c requirements.txt # authlib -flask==3.0.3 + # joserfc +flask==3.1.3 # via # -c requirements.txt # flask-multipass -flask-multipass==0.5.4 +flask-multipass==0.11.2 # via # -c requirements.txt # flask-multipass-cern -flask-multipass-cern==2.2.9 +flask-multipass-cern==2.3 # via -r requirements.cern.in -idna==3.7 +idna==3.20 # via # -c requirements.txt # requests @@ -47,29 +48,34 @@ itsdangerous==2.2.0 # via # -c requirements.txt # flask -jinja2==3.1.4 +jinja2==3.1.6 # via # -c requirements.txt # flask -markupsafe==2.1.5 +joserfc==1.7.7 # via # -c requirements.txt + # authlib +markupsafe==3.0.4 + # via + # -c requirements.txt + # flask # jinja2 # werkzeug -pycparser==2.22 +pycparser==3.11 # via # -c requirements.txt # cffi -requests==2.31.0 +requests==2.34.2 # via # -c requirements.txt # flask-multipass -urllib3==2.2.1 +urllib3==2.8.0 # via # -c requirements.txt # flask-multipass-cern # requests -werkzeug==3.0.3 +werkzeug==3.1.9 # via # -c requirements.txt # flask diff --git a/requirements.dev.txt b/requirements.dev.txt index a457b9b0..f45b91df 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -1,105 +1,110 @@ # This file was autogenerated by uv via the following command: # uv pip compile requirements.dev.in -o requirements.dev.txt -asttokens==2.4.1 +asttokens==3.0.2 # via stack-data -blinker==1.8.2 +blinker==1.9.0 # via # -c requirements.txt # flask -build==1.2.2.post1 +build==1.6.1 # via -r requirements.dev.in -click==8.1.7 +click==8.5.0 # via # -c requirements.txt # flask # flask-shell-ipython -coverage==7.5.1 +coverage==7.16.2 # via pytest-cov -decorator==5.1.1 - # via ipython -executing==2.0.1 +executing==2.3.0 # via stack-data -flask==3.0.3 +flask==3.1.3 # via # -c requirements.txt # flask-shell-ipython -flask-shell-ipython==0.5.1 +flask-shell-ipython==0.5.3 # via -r requirements.dev.in -iniconfig==2.0.0 +iniconfig==2.3.1 # via pytest -ipython==8.24.0 +ipython==9.17.1 # via # -r requirements.dev.in # flask-shell-ipython +ipython-pygments-lexers==1.1.1 + # via ipython itsdangerous==2.2.0 # via # -c requirements.txt # flask -jedi==0.19.1 +jedi==0.20.1 # via ipython -jinja2==3.1.4 +jinja2==3.1.6 # via # -c requirements.txt # flask -markupsafe==2.1.5 +markupsafe==3.0.4 # via # -c requirements.txt + # flask # jinja2 # werkzeug -matplotlib-inline==0.1.7 +matplotlib-inline==0.2.2 # via ipython -packaging==24.0 +packaging==26.3 # via # -c requirements.txt # build # pytest -parso==0.8.4 + # wheel +parso==0.8.7 # via jedi pexpect==4.9.0 # via ipython -pluggy==1.5.0 - # via pytest -prompt-toolkit==3.0.43 +pluggy==1.7.0 + # via + # pytest + # pytest-cov +prompt-toolkit==3.0.53 + # via ipython +psutil==7.2.2 # via ipython ptyprocess==0.7.0 # via pexpect -pure-eval==0.2.2 +pure-eval==0.2.4 # via stack-data -pygments==2.18.0 - # via ipython -pyproject-hooks==1.2.0 +pygments==2.21.0 + # via + # ipython + # ipython-pygments-lexers + # pytest +pyproject-hooks==1.3.3 # via build -pytest==8.2.0 +pytest==9.1.1 # via # -r requirements.dev.in # pytest-cov # pytest-mock # pytest-snapshot -pytest-cov==5.0.0 +pytest-cov==7.1.0 # via -r requirements.dev.in -pytest-mock==3.14.0 +pytest-mock==3.17.0 # via -r requirements.dev.in pytest-snapshot==0.9.0 # via -r requirements.dev.in -ruff==0.12.9 +ruff==0.17.1 # via -r requirements.dev.in -six==1.16.0 - # via - # -c requirements.txt - # asttokens stack-data==0.6.3 # via ipython -traitlets==5.14.3 +traitlets==5.16.1 # via # ipython # matplotlib-inline -uv==0.2.23 +uv==0.13.4 # via -r requirements.dev.in -wcwidth==0.2.13 +wcwidth==0.9.3 # via prompt-toolkit -werkzeug==3.0.3 +werkzeug==3.1.9 # via # -c requirements.txt # flask -wheel==0.43.0 +wheel==0.48.0 # via -r requirements.dev.in diff --git a/requirements.exchange.txt b/requirements.exchange.txt index 2aa1ee85..21eb96a0 100644 --- a/requirements.exchange.txt +++ b/requirements.exchange.txt @@ -1,20 +1,20 @@ # This file was autogenerated by uv via the following command: # uv pip compile requirements.exchange.in -o requirements.exchange.txt -cached-property==1.5.2 +cached-property==2.0.1 # via exchangelib -certifi==2024.2.2 +certifi==2026.10.19 # via # -c requirements.txt # requests -cffi==1.16.0 +cffi==2.1.1 # via # -c requirements.txt # cryptography -charset-normalizer==3.3.2 +charset-normalizer==3.5.2 # via # -c requirements.txt # requests -cryptography==42.0.7 +cryptography==50.0.2 # via # -c requirements.txt # msal @@ -23,56 +23,54 @@ cryptography==42.0.7 # requests-ntlm defusedxml==0.7.1 # via exchangelib -dnspython==2.6.1 +dnspython==2.9.0 # via exchangelib -exchangelib==5.3.0 +exchangelib==5.6.0 # via -r requirements.exchange.in -idna==3.7 +idna==3.20 # via # -c requirements.txt # requests -isodate==0.6.1 +isodate==0.7.2 # via exchangelib -lxml==5.2.1 +lxml==6.1.3 # via exchangelib -msal==1.28.0 +msal==1.39.0 # via -r requirements.exchange.in -oauthlib==3.2.2 +oauthlib==4.0.0 # via # exchangelib # requests-oauthlib -pycparser==2.22 +pycparser==3.11 # via # -c requirements.txt # cffi -pygments==2.18.0 +pygments==2.21.0 # via exchangelib -pyjwt==2.8.0 +pyjwt==2.15.1 # via msal -pyspnego==0.10.2 +pyspnego==0.12.4 # via requests-ntlm -requests==2.31.0 +requests==2.34.2 # via # -c requirements.txt # exchangelib # msal # requests-ntlm # requests-oauthlib -requests-ntlm==1.2.0 +requests-ntlm==1.3.0 # via exchangelib requests-oauthlib==2.0.0 # via exchangelib -six==1.16.0 +tzdata==2026.5 # via # -c requirements.txt - # isodate -tzdata==2024.1 - # via exchangelib + # exchangelib tzlocal==3.0 # via # -r requirements.exchange.in # exchangelib -urllib3==2.2.1 +urllib3==2.8.0 # via # -c requirements.txt # requests diff --git a/requirements.in b/requirements.in index 9477ea19..3b440794 100644 --- a/requirements.in +++ b/requirements.in @@ -10,10 +10,9 @@ flask icalendar itsdangerous jinja2 -marshmallow-enum marshmallow-sqlalchemy marshmallow -psycopg2 +psycopg python-dotenv pytz redis diff --git a/requirements.txt b/requirements.txt index f8eb5f0b..86180e5c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,32 +1,34 @@ # This file was autogenerated by uv via the following command: # uv pip compile requirements.in -o requirements.txt -alembic==1.13.1 +alembic==1.20.0 # via # -r requirements.in # flask-migrate -authlib==1.3.0 +authlib==1.9.1 # via flask-multipass -blinker==1.8.2 +blinker==1.9.0 # via # flask # flask-multipass -cachelib==0.9.0 +cachelib==0.17.0 # via flask-caching -certifi==2024.2.2 +certifi==2026.10.19 # via requests -cffi==1.16.0 +cffi==2.1.1 # via cryptography -charset-normalizer==3.3.2 +charset-normalizer==3.5.2 # via requests -click==8.1.7 +click==8.5.0 # via # flask # flask-url-map-serializer -cryptography==42.0.7 - # via authlib -faker==25.0.1 +cryptography==50.0.2 + # via + # authlib + # joserfc +faker==40.43.0 # via -r requirements.in -flask==3.0.3 +flask==3.1.3 # via # -r requirements.in # flask-caching @@ -35,13 +37,13 @@ flask==3.0.3 # flask-multipass # flask-sqlalchemy # flask-url-map-serializer -flask-caching==2.3.0 +flask-caching==2.5.1 # via -r requirements.in -flask-marshmallow==1.2.1 +flask-marshmallow==1.5.0 # via -r requirements.in -flask-migrate==4.0.7 +flask-migrate==4.1.0 # via -r requirements.in -flask-multipass==0.5.4 +flask-multipass==0.11.2 # via -r requirements.in flask-sqlalchemy==3.1.1 # via @@ -49,81 +51,77 @@ flask-sqlalchemy==3.1.1 # flask-migrate flask-url-map-serializer==0.0.1 # via -r requirements.in -greenlet==3.0.3 - # via sqlalchemy -icalendar==5.0.12 +icalendar==7.3.0 # via -r requirements.in -idna==3.7 +idna==3.20 # via requests itsdangerous==2.2.0 # via # -r requirements.in # flask -jinja2==3.1.4 +jinja2==3.1.6 # via # -r requirements.in # flask -mako==1.3.3 +joserfc==1.7.7 + # via authlib +mako==1.4.3 # via alembic -markupsafe==2.1.5 +markupsafe==3.0.4 # via + # flask # jinja2 # mako # werkzeug -marshmallow==3.21.2 +marshmallow==4.3.1 # via # -r requirements.in # flask-marshmallow - # marshmallow-enum # marshmallow-sqlalchemy # webargs -marshmallow-enum==1.5.1 +marshmallow-sqlalchemy==1.6.0 # via -r requirements.in -marshmallow-sqlalchemy==1.0.0 - # via -r requirements.in -packaging==24.0 - # via - # marshmallow - # webargs -psycopg2==2.9.9 +packaging==26.3 + # via webargs +psycopg==3.3.6 # via -r requirements.in -pycparser==2.22 +pycparser==3.11 # via cffi python-dateutil==2.9.0.post0 - # via - # faker - # icalendar -python-dotenv==1.0.1 + # via icalendar +python-dotenv==1.2.4 # via -r requirements.in -pytz==2024.1 - # via - # -r requirements.in - # icalendar -redis==5.0.7 +pytz==2026.5 + # via -r requirements.in +redis==8.1.0 # via -r requirements.in -requests==2.31.0 +requests==2.34.2 # via # -r requirements.in # flask-multipass -six==1.16.0 +six==1.17.0 # via python-dateutil -sqlalchemy==2.0.30 +sqlalchemy==2.1.6 # via # -r requirements.in # alembic # flask-sqlalchemy # marshmallow-sqlalchemy -typing-extensions==4.11.0 +typing-extensions==4.16.0 # via # alembic + # icalendar + # psycopg # sqlalchemy -urllib3==2.2.1 +tzdata==2026.5 + # via icalendar +urllib3==2.8.0 # via requests -webargs==8.4.0 +webargs==8.7.1 # via -r requirements.in -werkzeug==3.0.3 +werkzeug==3.1.9 # via # -r requirements.in # flask -xlsxwriter==3.2.0 +xlsxwriter==3.2.9 # via -r requirements.in diff --git a/ruff.toml b/ruff.toml index 5115f655..5cff3f98 100644 --- a/ruff.toml +++ b/ruff.toml @@ -1,4 +1,5 @@ target-version = 'py312' +output-prefer-rule-codes = true [lint] preview = true @@ -35,6 +36,7 @@ select = [ 'PERF', # perflint 'FURB', # refurb 'I', # isort + 'ERA', # eradicate ] ignore = [ 'E226', # allow omitting whitespace around arithmetic operators @@ -45,7 +47,9 @@ ignore = [ 'RUF022', # autofix messes up our formatting instead of just sorting 'RUF027', # also triggers on i18n functions -> too noisy for now 'RUF052', # we often use underscore-prefixed variables in tests and to cache regexps in function definitions - 'UP038', # it looks kind of weird and it slower than a tuple + 'RUF067', # we often have code in __init__.py + 'RUF105', # we use the noqa syntax in many places + 'RUF201', # we use rule codes everywhere 'D205', # too many docstrings which have no summary line 'D301', # https://github.com/astral-sh/ruff/issues/8696 'D1', # we have way too many missing docstrings :( @@ -79,6 +83,7 @@ ignore = [ 'PLR6201', # sets are faster (by a factor of 10!) but it's noisy and we're in nanoseconds territory 'PLR6301', # extremely noisy and generally annoying 'PLW0108', # a lambda often makes it more clear what you actually want + 'PLW0717', # noisy and currently also triggering on try..finally 'PLW1510', # we often do not care about the status code of commands 'PLW1514', # we expect UTF8 environments everywhere 'PLW1641', # false positives with SA comparator classes @@ -91,9 +96,7 @@ ignore = [ 'PERF203', # noisy, false positives, and not applicable for 3.11+ 'FURB113', # less readable 'FURB140', # less readable and actually slower in 3.12+ - 'PLW0603', # globals are fine here 'COM812', # formatter conflict - 'ISC001', # formatter conflict ] extend-safe-fixes = [ @@ -148,6 +151,6 @@ parenthesize-tuple-in-subscript = true [lint.per-file-ignores] # vendored code - don't care about most stuff in there -'newdle/vendor/*.py' = ['N', 'F841', 'UP', 'D', 'PIE', 'TID252', 'TRY', 'RUF059'] +'newdle/vendor/*.py' = ['N', 'F841', 'UP', 'D', 'PIE', 'TID252', 'TRY', 'RUF059', 'FURB101'] # allow long lines in migrations (only do that for raw SQL please) 'newdle/migrations/versions/*.py' = ['E501', 'D400'] diff --git a/tests/api_test.py b/tests/api_test.py index b4ed989b..02ed6356 100644 --- a/tests/api_test.py +++ b/tests/api_test.py @@ -1105,7 +1105,7 @@ def test_update_participant_answers_invalid(flask_client): 'answers': { 'foo': { 'key': ['Not a valid datetime.'], - 'value': ['Invalid enum member bar'], + 'value': ['Must be one of: unavailable, available, ifneedbe.'], } } },