Skip to content

Commit bf5ac26

Browse files
authored
switch to inbuilts (#9)
* switch to inbuilts
1 parent 0418520 commit bf5ac26

File tree

5 files changed

+24
-28
lines changed

5 files changed

+24
-28
lines changed

.devcontainer/devcontainer.json

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,12 @@
22
// README at: https://github.com/devcontainers/templates/tree/main/src/python
33
{
44
"name": "Python 3",
5-
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
65
"image": "mcr.microsoft.com/devcontainers/python:0-3.11",
76
"features": {
8-
"ghcr.io/devcontainers/features/python:1": {}
7+
"ghcr.io/devcontainers/features/python:1": {},
8+
"ghcr.io/devcontainers-contrib/features/black:1": {},
9+
"ghcr.io/devcontainers-contrib/features/tox:1": {},
10+
"ghcr.io/devcontainers-contrib/features/isort:1": {},
11+
"ghcr.io/devcontainers-contrib/features/poetry:1": {}
912
}
10-
11-
// Features to add to the dev container. More info: https://containers.dev/features.
12-
// "features": {},
13-
14-
// Use 'forwardPorts' to make a list of ports inside the container available locally.
15-
// "forwardPorts": [],
16-
17-
// Use 'postCreateCommand' to run commands after the container is created.
18-
// "postCreateCommand": "pip3 install --user -r requirements.txt",
19-
20-
// Configure tool-specific properties.
21-
// "customizations": {},
22-
23-
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
24-
// "remoteUser": "root"
25-
}
13+
}

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## [Unreleased]
44

5+
## [v1.2.3] - 2022-12-28
6+
7+
- Change to using inbuilt types rather than from `typing`
8+
59
## [v1.2.2] - 2022-12-23
610

711
### Added
@@ -42,3 +46,4 @@
4246
[v1.0.1]: https://github.com/jdkandersson/flake8-error-link/releases/v1.0.1
4347
[v1.1.0]: https://github.com/jdkandersson/flake8-error-link/releases/v1.1.0
4448
[v1.2.2]: https://github.com/jdkandersson/flake8-error-link/releases/v1.2.2
49+
[v1.2.3]: https://github.com/jdkandersson/flake8-error-link/releases/v1.2.3

flake8_error_link.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
"""A linter that ensures all raised Exceptions include an error with a link to more information."""
22

3+
from __future__ import annotations
4+
35
import argparse
46
import ast
57
import builtins
68
import re
79
from itertools import chain
8-
from typing import Generator, Iterable, List, NamedTuple, Optional, Tuple, Type
10+
from typing import Iterable, Iterator, NamedTuple
911

1012
from flake8.options.manager import OptionManager
1113

@@ -56,7 +58,7 @@ class Visitor(ast.NodeVisitor):
5658
information was included.
5759
"""
5860

59-
problems: List[Problem]
61+
problems: list[Problem]
6062
_more_info_regex: re.Pattern
6163

6264
def __init__(self, more_info_regex: str = DEFAULT_REGEX) -> None:
@@ -184,7 +186,7 @@ def _iter_arg(node: ast.expr) -> Iterable[ast.expr]:
184186
yield from Visitor._iter_arg_call(node)
185187

186188
@staticmethod
187-
def _iter_args(nodes: List[ast.expr]) -> Iterable[ast.expr]:
189+
def _iter_args(nodes: list[ast.expr]) -> Iterable[ast.expr]:
188190
"""Iterate over the args whilst flatenning certain argument types.
189191
190192
Args:
@@ -241,7 +243,7 @@ def _includes_link(self, node: ast.Call) -> bool:
241243
is not None
242244
)
243245

244-
def _node_problem_message(self, node: ast.Raise) -> Optional[str]:
246+
def _node_problem_message(self, node: ast.Raise) -> str | None:
245247
"""Check whether a node has a problem.
246248
247249
Invalid nodes:
@@ -340,7 +342,7 @@ def parse_options(cls, options: argparse.Namespace) -> None: # pragma: nocover
340342
"""
341343
cls._error_link_regex = options.error_link_regex or cls._error_link_regex
342344

343-
def run(self) -> Generator[Tuple[int, int, str, Type["Plugin"]], None, None]:
345+
def run(self) -> Iterator[tuple[int, int, str, type["Plugin"]]]:
344346
"""Lint a file.
345347
346348
Yields:

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[tool.poetry]
22
name = "flake8-error-link"
3-
version = "1.2.2"
3+
version = "1.2.3"
44
description = "A linter that ensures all raised Exceptions include an error with a link to more information"
5-
authors = ["David Andersson <[email protected].com>"]
5+
authors = ["David Andersson <david@jdkandersson.com>"]
66
license = "Apache 2.0"
77
readme = "README.md"
88
packages = [{include = "flake8_error_link.py"}]

tests/test_flake8_error_link.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
"""Tests for plugin."""
22

3+
from __future__ import annotations
4+
35
import ast
46
import subprocess
57
import sys
68
from pathlib import Path
7-
from typing import Tuple
89

910
import pytest
1011

@@ -24,7 +25,7 @@
2425
_VALID_RAISE_MSG = "more information: http://example.com"
2526

2627

27-
def _result(code: str) -> Tuple[str, ...]:
28+
def _result(code: str) -> tuple[str, ...]:
2829
"""Generate linting results.
2930
3031
Args:
@@ -335,7 +336,7 @@ def _result(code: str) -> Tuple[str, ...]:
335336
),
336337
],
337338
)
338-
def test_plugin(code: str, expected_result: Tuple[str, ...]):
339+
def test_plugin(code: str, expected_result: tuple[str, ...]):
339340
"""
340341
given: code
341342
when: linting is run on the code

0 commit comments

Comments
 (0)