Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
68958ae
Warn only where code reads PermitException
zeevmoney Oct 2, 2026
b08f052
Check that type checkers flag PermitException
zeevmoney Oct 2, 2026
9b18b6c
List PermitException under the README's Deprecations
zeevmoney Oct 2, 2026
c69e448
Drop the import-warning filter from the migration guide's -W run
zeevmoney Oct 2, 2026
489a1f1
Merge the PermitException deprecation branch
zeevmoney Oct 2, 2026
f0fbde5
Check that the package's PermitException is deprecated for mypy
zeevmoney Oct 2, 2026
c117079
Say which releases need the PermitException import filter
zeevmoney Oct 2, 2026
66be83d
Leave PermitException out of the modules' dir()
zeevmoney Oct 2, 2026
9a99e57
Test each guard of the deprecated-name warning helper
zeevmoney Oct 2, 2026
fdb9e80
Say which PermitException reads warn, and how to filter them
zeevmoney Oct 2, 2026
36bd955
Say that a star import does not bind PermitException
zeevmoney Oct 2, 2026
7276796
Bind PermitException in star imports through __all__
zeevmoney Oct 2, 2026
0e9cc43
Drop the X as X re-export aliases that __all__ replaces
zeevmoney Oct 2, 2026
9889fb8
Say that a star import binds PermitException and warns once
zeevmoney Oct 2, 2026
5e73894
Say to list new API models in the package's __all__
zeevmoney Oct 2, 2026
06ba2db
Merge the timeout-0 docs fix from the base branch
zeevmoney Oct 2, 2026
3d37d77
Merge the lifecycle test fix from the base branch
zeevmoney Oct 2, 2026
2856cbb
Merge the review fixes from the base branch
zeevmoney Oct 2, 2026
352a59e
Merge the base branch's backported e2e and schema fixes
zeevmoney Oct 2, 2026
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
8 changes: 7 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,13 @@ has to be restored by hand.
4. Do not run `ruff format` on it: `permit/api/models.py` is excluded from ruff and typos
in `pyproject.toml` and keeps the generator's formatting, so the diff shows only API changes.

5. Run the schema drift check, the offline tests under both pydantic majors (see above) and
5. Add each new model to `__all__` in `permit/__init__.py`, and remove each deleted one:
`from permit import *` binds only the names `__all__` lists, and type checkers treat only
those as exported. `tests/test_fix_permit_exception_deprecation.py` fails until the list
matches. A name the models import for their own use, such as one from `typing`, goes in that
test's `NOT_EXPORTED` instead.

6. Run the schema drift check, the offline tests under both pydantic majors (see above) and
`uv run pre-commit run --all-files`.

### Schema drift check
Expand Down
15 changes: 10 additions & 5 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -467,13 +467,17 @@ summary.
request is sent:

```bash
python -m pytest -W error::DeprecationWarning -W "ignore:Use PermitError instead:DeprecationWarning"
python -m pytest -W error::DeprecationWarning
```

The second filter is needed in 2.x and 3.x alike: `import permit` warns because
`PermitConnectionError` subclasses the deprecated `PermitException`, and that warning comes from
inside the SDK. To fail on permit's flat methods only, use
`-W "error:permit.api.:DeprecationWarning"`.
It also fails on each line that imports `PermitException`, or reads `permit.PermitException`
or `permit.exceptions.PermitException`, as that line runs (an `except` clause reads it only
when an exception reaches it). A star import of `permit` or `permit.exceptions` binds
`PermitException`, so it fails too, even where the code never uses the name: import the names
the code uses instead. permit 4.0 removes `PermitException`: catch `PermitConnectionError`
instead. permit 2.7.0 to 3.0.0 warn on `import permit` itself ("Use PermitError instead"),
from inside the SDK; on those, add `-W "ignore:Use PermitError instead:DeprecationWarning"`.
To fail on permit's flat methods only, use `-W "error:permit.api.:DeprecationWarning"`.
- **To silence them** while you migrate, add filters for the messages:

```ini
Expand All @@ -482,6 +486,7 @@ summary.
filterwarnings =
ignore:permit\.api\.\w+\(\) is deprecated:DeprecationWarning
ignore:Support for pydantic 1:DeprecationWarning
ignore:PermitException is deprecated:DeprecationWarning
```

In code: `warnings.filterwarnings("ignore", message=r"permit\.api\.\w+\(\) is deprecated", category=DeprecationWarning)`.
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,18 @@ each one issues a `DeprecationWarning` that says what to do instead.
query parameter the API has deprecated. Use `permit.api.resource_instances.list_detailed()`
instead (see [Detailed lists](#detailed-lists)). Only a call that passes `detailed_key=True`
or `detailed_key=False` warns.
- **`PermitException`.** Catch `PermitConnectionError` instead: it is the only exception the
SDK raises that is a `PermitException`. permit 4.0 makes `PermitConnectionError` a direct
subclass of `PermitError`, so handlers of `PermitError` or `PermitConnectionError` keep
working. Importing `PermitException`, or reading `permit.PermitException` or
`permit.exceptions.PermitException`, warns at that line when it runs; later uses of an
imported name do not. Type checkers flag it: mypy with `--enable-error-code deprecated`,
pyright in strict mode. `import permit` does not issue this warning. A star import of
`permit` or `permit.exceptions` binds `PermitException`, so it warns once, at the star-import
line, even where the code never uses the name; importing the names the code uses avoids it.
Until you change the code, the warning filter
`ignore:PermitException is deprecated:DeprecationWarning` silences it. Filters for the
message of earlier releases, "Use PermitError instead", do not match it.

By default, Python shows these warnings only when the code that triggers them is in
`__main__`, such as the script you run. pytest shows them in its warnings summary. To see
Expand Down
Loading
Loading