Skip to content

Commit

Permalink
drop python3.6 support
Browse files Browse the repository at this point in the history
python 3.6 reached end of life on 2021-12-23

Committed via https://github.com/asottile/all-repos
  • Loading branch information
asottile committed Jan 15, 2022
1 parent 416900a commit 7f27633
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ repos:
rev: v2.6.0
hooks:
- id: reorder-python-imports
args: [--py3-plus]
args: [--py37-plus, --add-import, 'from __future__ import annotations']
- repo: https://github.com/asottile/add-trailing-comma
rev: v2.2.1
hooks:
Expand All @@ -38,7 +38,7 @@ repos:
rev: v2.31.0
hooks:
- id: pyupgrade
args: [--py36-plus]
args: [--py37-plus]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.931
hooks:
Expand Down
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ resources:
type: github
endpoint: github
name: asottile/azure-pipeline-templates
ref: refs/tags/v2.1.0
ref: refs/tags/v2.4.0

jobs:
- template: job--python-tox.yml@asottile
parameters:
toxenvs: [pypy3, py36, py37, py38]
toxenvs: [py37, py38]
os: linux
2 changes: 2 additions & 0 deletions bin/vendor-licenses
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
./bin/vendor-licenses > identify/vendor/licenses.py
"""
from __future__ import annotations

import argparse
import os.path
import subprocess
Expand Down
5 changes: 3 additions & 2 deletions identify/cli.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from __future__ import annotations

import argparse
import json
from typing import Optional
from typing import Sequence

from identify import identify


def main(argv: Optional[Sequence[str]] = None) -> int:
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('--filename-only', action='store_true')
parser.add_argument('path')
Expand Down
1 change: 1 addition & 0 deletions identify/extensions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
EXTENSIONS = {
'adoc': {'text', 'asciidoc'},
'ai': {'binary', 'adobe-illustrator'},
Expand Down
24 changes: 11 additions & 13 deletions identify/identify.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import errno
import math
import os.path
Expand All @@ -7,10 +9,6 @@
import string
import sys
from typing import IO
from typing import List
from typing import Optional
from typing import Set
from typing import Tuple

from identify import extensions
from identify import interpreters
Expand Down Expand Up @@ -39,7 +37,7 @@
ALL_TAGS = frozenset(_ALL_TAGS)


def tags_from_path(path: str) -> Set[str]:
def tags_from_path(path: str) -> set[str]:
try:
sr = os.lstat(path)
except (OSError, ValueError): # same error-handling as `os.lexists()`
Expand Down Expand Up @@ -85,7 +83,7 @@ def tags_from_path(path: str) -> Set[str]:
return tags


def tags_from_filename(path: str) -> Set[str]:
def tags_from_filename(path: str) -> set[str]:
_, filename = os.path.split(path)
_, ext = os.path.splitext(filename)

Expand All @@ -107,7 +105,7 @@ def tags_from_filename(path: str) -> Set[str]:
return ret


def tags_from_interpreter(interpreter: str) -> Set[str]:
def tags_from_interpreter(interpreter: str) -> set[str]:
_, _, interpreter = interpreter.rpartition('/')

# Try "python3.5.2" => "python3.5" => "python3" until one matches.
Expand Down Expand Up @@ -141,7 +139,7 @@ def file_is_text(path: str) -> bool:
return is_text(f)


def _shebang_split(line: str) -> List[str]:
def _shebang_split(line: str) -> list[str]:
try:
# shebangs aren't supposed to be quoted, though some tools such as
# setuptools will write them with quotes so we'll best-guess parse
Expand All @@ -155,8 +153,8 @@ def _shebang_split(line: str) -> List[str]:

def _parse_nix_shebang(
bytesio: IO[bytes],
cmd: Tuple[str, ...],
) -> Tuple[str, ...]:
cmd: tuple[str, ...],
) -> tuple[str, ...]:
while bytesio.read(2) == b'#!':
next_line_b = bytesio.readline()
try:
Expand All @@ -177,7 +175,7 @@ def _parse_nix_shebang(
return cmd


def parse_shebang(bytesio: IO[bytes]) -> Tuple[str, ...]:
def parse_shebang(bytesio: IO[bytes]) -> tuple[str, ...]:
"""Parse the shebang from a file opened for reading binary."""
if bytesio.read(2) != b'#!':
return ()
Expand All @@ -204,7 +202,7 @@ def parse_shebang(bytesio: IO[bytes]) -> Tuple[str, ...]:
return cmd


def parse_shebang_from_file(path: str) -> Tuple[str, ...]:
def parse_shebang_from_file(path: str) -> tuple[str, ...]:
"""Parse the shebang given a file path."""
if not os.path.lexists(path):
raise ValueError(f'{path} does not exist.')
Expand All @@ -231,7 +229,7 @@ def _norm_license(s: str) -> str:
return s.strip()


def license_id(filename: str) -> Optional[str]:
def license_id(filename: str) -> str | None:
"""Return the spdx id for the license contained in `filename`. If no
license is detected, returns `None`.
Expand Down
1 change: 1 addition & 0 deletions identify/interpreters.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
INTERPRETERS = {
'ash': {'shell', 'ash'},
'awk': {'awk'},
Expand Down
1 change: 1 addition & 0 deletions identify/vendor/licenses.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
LICENSES = (
(
'0BSD',
Expand Down
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ classifiers =
License :: OSI Approved :: MIT License
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Expand All @@ -23,7 +22,7 @@ classifiers =

[options]
packages = find:
python_requires = >=3.6.1
python_requires = >=3.7

[options.packages.find]
exclude =
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
from __future__ import annotations

from setuptools import setup
setup()
2 changes: 2 additions & 0 deletions tests/cli_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from identify import cli


Expand Down
2 changes: 2 additions & 0 deletions tests/extensions_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import pytest

from identify import extensions
Expand Down
2 changes: 2 additions & 0 deletions tests/identify_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import builtins
import errno
import io
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py36,pypy3,pre-commit
envlist = py37,pypy3,pre-commit

[testenv]
deps = -rrequirements-dev.txt
Expand Down

0 comments on commit 7f27633

Please sign in to comment.