1
0
Fork 0

Merging upstream version 2.4.6.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-12 21:56:08 +01:00
parent 829c0008f8
commit e7b4550ffe
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
14 changed files with 37 additions and 24 deletions

View file

@ -19,7 +19,7 @@ repos:
hooks: hooks:
- id: flake8 - id: flake8
exclude: ^identify/vendor/licenses\.py$ exclude: ^identify/vendor/licenses\.py$
additional_dependencies: [flake8-typing-imports==1.10.1] additional_dependencies: [flake8-typing-imports==1.12.0]
- repo: https://github.com/pre-commit/mirrors-autopep8 - repo: https://github.com/pre-commit/mirrors-autopep8
rev: v1.6.0 rev: v1.6.0
hooks: hooks:
@ -28,7 +28,7 @@ repos:
rev: v2.6.0 rev: v2.6.0
hooks: hooks:
- id: reorder-python-imports - id: reorder-python-imports
args: [--py3-plus] args: [--py37-plus, --add-import, 'from __future__ import annotations']
- repo: https://github.com/asottile/add-trailing-comma - repo: https://github.com/asottile/add-trailing-comma
rev: v2.2.1 rev: v2.2.1
hooks: hooks:
@ -38,7 +38,7 @@ repos:
rev: v2.31.0 rev: v2.31.0
hooks: hooks:
- id: pyupgrade - id: pyupgrade
args: [--py36-plus] args: [--py37-plus]
- repo: https://github.com/pre-commit/mirrors-mypy - repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.931 rev: v0.931
hooks: hooks:

View file

@ -10,10 +10,10 @@ resources:
type: github type: github
endpoint: github endpoint: github
name: asottile/azure-pipeline-templates name: asottile/azure-pipeline-templates
ref: refs/tags/v2.1.0 ref: refs/tags/v2.4.0
jobs: jobs:
- template: job--python-tox.yml@asottile - template: job--python-tox.yml@asottile
parameters: parameters:
toxenvs: [pypy3, py36, py37, py38] toxenvs: [py37, py38]
os: linux os: linux

View file

@ -3,6 +3,8 @@
./bin/vendor-licenses > identify/vendor/licenses.py ./bin/vendor-licenses > identify/vendor/licenses.py
""" """
from __future__ import annotations
import argparse import argparse
import os.path import os.path
import subprocess import subprocess

View file

@ -1,12 +1,13 @@
from __future__ import annotations
import argparse import argparse
import json import json
from typing import Optional
from typing import Sequence from typing import Sequence
from identify import identify from identify import identify
def main(argv: Optional[Sequence[str]] = None) -> int: def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('--filename-only', action='store_true') parser.add_argument('--filename-only', action='store_true')
parser.add_argument('path') parser.add_argument('path')

View file

@ -1,3 +1,4 @@
from __future__ import annotations
EXTENSIONS = { EXTENSIONS = {
'adoc': {'text', 'asciidoc'}, 'adoc': {'text', 'asciidoc'},
'ai': {'binary', 'adobe-illustrator'}, 'ai': {'binary', 'adobe-illustrator'},
@ -79,6 +80,7 @@ EXTENSIONS = {
'idr': {'text', 'idris'}, 'idr': {'text', 'idris'},
'inc': {'text', 'inc'}, 'inc': {'text', 'inc'},
'ini': {'text', 'ini'}, 'ini': {'text', 'ini'},
'inl': {'text', 'inl', 'c++'},
'ino': {'text', 'ino', 'c++'}, 'ino': {'text', 'ino', 'c++'},
'inx': {'text', 'xml', 'inx'}, 'inx': {'text', 'xml', 'inx'},
'ipynb': {'text', 'jupyter'}, 'ipynb': {'text', 'jupyter'},
@ -177,6 +179,7 @@ EXTENSIONS = {
'spec': {'text', 'spec'}, 'spec': {'text', 'spec'},
'sql': {'text', 'sql'}, 'sql': {'text', 'sql'},
'ss': {'text', 'scheme'}, 'ss': {'text', 'scheme'},
'sty': {'text', 'tex'},
'styl': {'text', 'stylus'}, 'styl': {'text', 'stylus'},
'sv': {'text', 'system-verilog'}, 'sv': {'text', 'system-verilog'},
'svelte': {'text', 'svelte'}, 'svelte': {'text', 'svelte'},

View file

@ -1,3 +1,5 @@
from __future__ import annotations
import errno import errno
import math import math
import os.path import os.path
@ -7,10 +9,6 @@ import stat
import string import string
import sys import sys
from typing import IO 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 extensions
from identify import interpreters from identify import interpreters
@ -39,7 +37,7 @@ _ALL_TAGS.update(*interpreters.INTERPRETERS.values())
ALL_TAGS = frozenset(_ALL_TAGS) ALL_TAGS = frozenset(_ALL_TAGS)
def tags_from_path(path: str) -> Set[str]: def tags_from_path(path: str) -> set[str]:
try: try:
sr = os.lstat(path) sr = os.lstat(path)
except (OSError, ValueError): # same error-handling as `os.lexists()` except (OSError, ValueError): # same error-handling as `os.lexists()`
@ -85,7 +83,7 @@ def tags_from_path(path: str) -> Set[str]:
return tags return tags
def tags_from_filename(path: str) -> Set[str]: def tags_from_filename(path: str) -> set[str]:
_, filename = os.path.split(path) _, filename = os.path.split(path)
_, ext = os.path.splitext(filename) _, ext = os.path.splitext(filename)
@ -107,7 +105,7 @@ def tags_from_filename(path: str) -> Set[str]:
return ret return ret
def tags_from_interpreter(interpreter: str) -> Set[str]: def tags_from_interpreter(interpreter: str) -> set[str]:
_, _, interpreter = interpreter.rpartition('/') _, _, interpreter = interpreter.rpartition('/')
# Try "python3.5.2" => "python3.5" => "python3" until one matches. # Try "python3.5.2" => "python3.5" => "python3" until one matches.
@ -141,7 +139,7 @@ def file_is_text(path: str) -> bool:
return is_text(f) return is_text(f)
def _shebang_split(line: str) -> List[str]: def _shebang_split(line: str) -> list[str]:
try: try:
# shebangs aren't supposed to be quoted, though some tools such as # shebangs aren't supposed to be quoted, though some tools such as
# setuptools will write them with quotes so we'll best-guess parse # setuptools will write them with quotes so we'll best-guess parse
@ -155,8 +153,8 @@ def _shebang_split(line: str) -> List[str]:
def _parse_nix_shebang( def _parse_nix_shebang(
bytesio: IO[bytes], bytesio: IO[bytes],
cmd: Tuple[str, ...], cmd: tuple[str, ...],
) -> Tuple[str, ...]: ) -> tuple[str, ...]:
while bytesio.read(2) == b'#!': while bytesio.read(2) == b'#!':
next_line_b = bytesio.readline() next_line_b = bytesio.readline()
try: try:
@ -177,7 +175,7 @@ def _parse_nix_shebang(
return cmd 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.""" """Parse the shebang from a file opened for reading binary."""
if bytesio.read(2) != b'#!': if bytesio.read(2) != b'#!':
return () return ()
@ -204,7 +202,7 @@ def parse_shebang(bytesio: IO[bytes]) -> Tuple[str, ...]:
return cmd 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.""" """Parse the shebang given a file path."""
if not os.path.lexists(path): if not os.path.lexists(path):
raise ValueError(f'{path} does not exist.') raise ValueError(f'{path} does not exist.')
@ -231,7 +229,7 @@ def _norm_license(s: str) -> str:
return s.strip() 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 """Return the spdx id for the license contained in `filename`. If no
license is detected, returns `None`. license is detected, returns `None`.

View file

@ -1,3 +1,4 @@
from __future__ import annotations
INTERPRETERS = { INTERPRETERS = {
'ash': {'shell', 'ash'}, 'ash': {'shell', 'ash'},
'awk': {'awk'}, 'awk': {'awk'},

View file

@ -1,3 +1,4 @@
from __future__ import annotations
LICENSES = ( LICENSES = (
( (
'0BSD', '0BSD',

View file

@ -1,6 +1,6 @@
[metadata] [metadata]
name = identify name = identify
version = 2.4.4 version = 2.4.6
description = File identification library for Python description = File identification library for Python
long_description = file: README.md long_description = file: README.md
long_description_content_type = text/markdown long_description_content_type = text/markdown
@ -13,7 +13,6 @@ classifiers =
License :: OSI Approved :: MIT License License :: OSI Approved :: MIT License
Programming Language :: Python :: 3 Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.9
@ -23,7 +22,7 @@ classifiers =
[options] [options]
packages = find: packages = find:
python_requires = >=3.6.1 python_requires = >=3.7
[options.packages.find] [options.packages.find]
exclude = exclude =

View file

@ -1,2 +1,4 @@
from __future__ import annotations
from setuptools import setup from setuptools import setup
setup() setup()

View file

@ -1,3 +1,5 @@
from __future__ import annotations
from identify import cli from identify import cli

View file

@ -1,3 +1,5 @@
from __future__ import annotations
import pytest import pytest
from identify import extensions from identify import extensions

View file

@ -1,3 +1,5 @@
from __future__ import annotations
import builtins import builtins
import errno import errno
import io import io

View file

@ -1,5 +1,5 @@
[tox] [tox]
envlist = py36,pypy3,pre-commit envlist = py37,pypy3,pre-commit
[testenv] [testenv]
deps = -rrequirements-dev.txt deps = -rrequirements-dev.txt