Skip to content

Commit

Permalink
Merge pull request #205 from jakkdl/remove_117
Browse files Browse the repository at this point in the history
remove trio117, as MultiError is removed in trio 0.24.0
  • Loading branch information
Zac-HD authored Feb 23, 2024
2 parents dffdf7d + c28b7e5 commit b00e77a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 73 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog
*[CalVer, YY.month.patch](https://calver.org/)*

## Future
- Removed TRIO117, MultiError removed in trio 0.24.0

## 23.5.1
- TRIO91X now supports comprehensions
- TRIO100 and TRIO91X now supports autofixing
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ pip install flake8-trio
- **TRIO104**: `Cancelled` and `BaseException` must be re-raised - when a user tries to `return` or `raise` a different exception.
- **TRIO105**: Calling a trio async function without immediately `await`ing it.
- **TRIO106**: `trio` must be imported with `import trio` for the linter to work.
- **TRIO107**: Renamed to TRIO910
- **TRIO108**: Renamed to TRIO911
- **TRIO109**: Async function definition with a `timeout` parameter - use `trio.[fail/move_on]_[after/at]` instead
- **TRIO110**: `while <condition>: await trio.sleep()` should be replaced by a `trio.Event`.
- **TRIO111**: Variable, from context manager opened inside nursery, passed to `start[_soon]` might be invalidly accessed while in use, due to context manager closing before the nursery. This is usually a bug, and nurseries should generally be the inner-most context manager.
Expand All @@ -42,7 +40,6 @@ pip install flake8-trio
- **TRIO114**: Startable function (i.e. has a `task_status` keyword parameter) not in `--startable-in-context-manager` parameter list, please add it so TRIO113 can catch errors when using it.
- **TRIO115**: Replace `trio.sleep(0)` with the more suggestive `trio.lowlevel.checkpoint()`.
- **TRIO116**: `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()`.
- **TRIO117**: Don't raise or catch `trio.[NonBase]MultiError`, prefer `[exceptiongroup.]BaseExceptionGroup`. Even if Trio still raises `MultiError` for legacy code, it can be caught with `BaseExceptionGroup` so it's fully redundant.
- **TRIO118**: Don't assign the value of `anyio.get_cancelled_exc_class()` to a variable, since that breaks linter checks and multi-backend programs.

### Warnings for blocking sync calls in async functions
Expand All @@ -58,13 +55,17 @@ pip install flake8-trio
- **TRIO232**: Blocking sync call on file object, wrap the file object in `trio.wrap_file()` to get an async file object.
- **TRIO240**: Avoid using `os.path` in async functions, prefer using `trio.Path` objects.


### Warnings disabled by default
- **TRIO900**: Async generator without `@asynccontextmanager` not allowed.
- **TRIO910**: Exit or `return` from async function with no guaranteed checkpoint or exception since function definition.
- **TRIO911**: Exit, `yield` or `return` from async iterable with no guaranteed checkpoint since possible function entry (yield or function definition)
Checkpoints are `await`, `async for`, and `async with` (on one of enter/exit).

### Removed Warnings
- **TRIO107**: Renamed to TRIO910
- **TRIO108**: Renamed to TRIO911
- **TRIO117**: Don't raise or catch `trio.[NonBase]MultiError`, prefer `[exceptiongroup.]BaseExceptionGroup`. `MultiError` was removed in trio==0.24.0.

## Examples
### install and run through flake8
```sh
Expand Down
20 changes: 0 additions & 20 deletions flake8_trio/visitors/visitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,26 +264,6 @@ def visit_Call(self, node: ast.Call):
self.error(node, m[2])


DEPRECATED_ERRORS = ("MultiError", "NonBaseMultiError")


# anyio does not have MultiError, so this check is trio-only
@error_class
class Visitor117(Flake8TrioVisitor):
error_codes: Mapping[str, str] = {
"TRIO117": "Reference to {}, prefer [exceptiongroup.]BaseExceptionGroup.",
}

# This should never actually happen given TRIO106
def visit_Name(self, node: ast.Name):
if node.id in DEPRECATED_ERRORS and "trio" in self.library:
self.error(node, node.id)

def visit_Attribute(self, node: ast.Attribute):
if (n := ast.unparse(node)) in ("trio.MultiError", "trio.NonBaseMultiError"):
self.error(node, n)


@error_class
@disabled_by_default
class Visitor900(Flake8TrioVisitor):
Expand Down
47 changes: 0 additions & 47 deletions tests/eval_files/trio117.py

This file was deleted.

4 changes: 2 additions & 2 deletions tests/test_messages_documented.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
CHANGELOG = ROOT_PATH / "CHANGELOG.md"
README = CHANGELOG.parent / "README.md"

# 107 & 108 are removed (but still mentioned in changelog & readme)
# 107, 108 & 117 are removed (but still mentioned in changelog & readme)
# TRIOxxx_* are fake codes to get different error messages for the same code
IGNORED_CODES_REGEX = r"TRIO107|TRIO108|TRIO\d\d\d_.*"
IGNORED_CODES_REGEX = r"TRIO107|TRIO108|TRIO117|TRIO\d\d\d_.*"


def test_messages_documented():
Expand Down

0 comments on commit b00e77a

Please sign in to comment.