Skip to content

Commit

Permalink
Merge pull request #1080 from carmenbianca/remove-3.8
Browse files Browse the repository at this point in the history
Remove Python 3.8 support
  • Loading branch information
carmenbianca authored Sep 26, 2024
2 parents aea0d07 + f162262 commit 8615ea7
Show file tree
Hide file tree
Showing 21 changed files with 147 additions and 200 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ jobs:
# do not abort the whole test job if one combination in the matrix fails
fail-fast: false
matrix:
python-version: ["3.8", "3.12"]
python-version: ["3.9", "3.12"]
os: [ubuntu-22.04]
include:
- python-version: "3.8"
- python-version: "3.9"
os: macos-latest
- python-version: "3.8"
- python-version: "3.9"
os: windows-latest

steps:
Expand All @@ -49,7 +49,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies
run: |
pip install poetry~=1.3.0
Expand All @@ -65,7 +65,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies
run: |
pip install poetry~=1.3.0
Expand All @@ -82,7 +82,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies
run: |
pip install poetry~=1.3.0
Expand All @@ -108,7 +108,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies
run: |
pip install poetry~=1.3.0
Expand All @@ -123,7 +123,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies
run: |
pip install poetry~=1.3.0
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/third_party_lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies
run: |
pip install poetry~=1.3.0
Expand All @@ -56,7 +56,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies
run: |
pip install poetry~=1.3.0
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build:
# This should mirror the configuration in ./.github/workflows/test.yaml
os: ubuntu-22.04
tools:
python: "3.8"
python: "3.9"
jobs:
post_create_environment:
- python -m pip install poetry
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ recommendations.
- Source code: <https://github.com/fsfe/reuse-tool>
- PyPI: <https://pypi.python.org/pypi/reuse>
- REUSE: 3.3
- Python: 3.8+
- Python: 3.9+

## Table of contents

Expand Down
1 change: 1 addition & 0 deletions changelog.d/removed/python-3.8.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Python 3.8 support removed. (#1080)
20 changes: 3 additions & 17 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ classifiers = [
]

[tool.poetry.dependencies]
python = "^3.8"
python = "^3.9"
Jinja2 = ">=3.0.0"
binaryornot = ">=0.4.4"
"boolean.py" = ">=3.8"
license-expression = ">=1.0"
python-debian = ">=0.1.34,!=0.1.45,!=0.1.46,!=0.1.47"
# TODO: Consider removing this dependency in favour of tomllib when dropping
# Python 3.10.
tomlkit = ">=0.8"
attrs = ">=21.3"

Expand Down
15 changes: 9 additions & 6 deletions src/reuse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@
change the public API.
"""

# TODO: When Python 3.9 is dropped, consider using `type | None` instead of
# `Optional[type]`.

import gettext
import logging
import os
import re
from dataclasses import dataclass, field
from enum import Enum
from importlib.metadata import PackageNotFoundError, version
from typing import Any, Dict, NamedTuple, Optional, Set, Type
from typing import Any, Optional

from boolean.boolean import Expression

Expand Down Expand Up @@ -108,9 +111,9 @@ class SourceType(Enum):
class ReuseInfo:
"""Simple dataclass holding licensing and copyright information"""

spdx_expressions: Set[Expression] = field(default_factory=set)
copyright_lines: Set[str] = field(default_factory=set)
contributor_lines: Set[str] = field(default_factory=set)
spdx_expressions: set[Expression] = field(default_factory=set)
copyright_lines: set[str] = field(default_factory=set)
contributor_lines: set[str] = field(default_factory=set)
path: Optional[str] = None
source_path: Optional[str] = None
source_type: Optional[SourceType] = None
Expand All @@ -134,10 +137,10 @@ def copy(self, **kwargs: Any) -> "ReuseInfo":
return self.__class__(**new_kwargs) # type: ignore

def union(self, value: "ReuseInfo") -> "ReuseInfo":
"""Return a new instance of ReuseInfo where all Set attributes are equal
"""Return a new instance of ReuseInfo where all set attributes are equal
to the union of the set in *self* and the set in *value*.
All non-Set attributes are set to their values in *self*.
All non-set attributes are set to their values in *self*.
>>> one = ReuseInfo(copyright_lines={"Jane Doe"}, source_path="foo.py")
>>> two = ReuseInfo(copyright_lines={"John Doe"}, source_path="bar.py")
Expand Down
8 changes: 4 additions & 4 deletions src/reuse/_annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from argparse import SUPPRESS, ArgumentParser, Namespace
from gettext import gettext as _
from pathlib import Path
from typing import IO, Iterable, Optional, Set, Tuple, Type, cast
from typing import IO, Iterable, Optional, Type, cast

from binaryornot.check import is_binary
from jinja2 import Environment, FileSystemLoader, Template
Expand Down Expand Up @@ -232,13 +232,13 @@ def test_mandatory_option_required(args: Namespace) -> None:
)


def all_paths(args: Namespace, project: Project) -> Set[Path]:
def all_paths(args: Namespace, project: Project) -> set[Path]:
"""Return a set of all provided paths, converted into .license paths if they
exist. If recursive is enabled, all files belonging to *project* are also
added.
"""
if args.recursive:
paths: Set[Path] = set()
paths: set[Path] = set()
all_files = [path.resolve() for path in project.all_files()]
for path in args.path:
if path.is_file():
Expand All @@ -256,7 +256,7 @@ def all_paths(args: Namespace, project: Project) -> Set[Path]:

def get_template(
args: Namespace, project: Project
) -> Tuple[Optional[Template], bool]:
) -> tuple[Optional[Template], bool]:
"""If a template is specified on the CLI, find and return it, including
whether it is a 'commented' template.
Expand Down
5 changes: 2 additions & 3 deletions src/reuse/_licenses.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@

import json
import os
from typing import Dict, List, Tuple

_BASE_DIR = os.path.dirname(__file__)
_RESOURCES_DIR = os.path.join(_BASE_DIR, "resources")
_LICENSES = os.path.join(_RESOURCES_DIR, "licenses.json")
_EXCEPTIONS = os.path.join(_RESOURCES_DIR, "exceptions.json")


def _load_license_list(file_name: str) -> Tuple[List[int], Dict[str, Dict]]:
def _load_license_list(file_name: str) -> tuple[list[int], dict[str, dict]]:
"""Return the licenses list version tuple and a mapping of licenses
id->name loaded from a JSON file
from https://github.com/spdx/license-list-data
Expand All @@ -34,7 +33,7 @@ def _load_license_list(file_name: str) -> Tuple[List[int], Dict[str, Dict]]:
return version, licenses_map


def _load_exception_list(file_name: str) -> Tuple[List[int], Dict[str, Dict]]:
def _load_exception_list(file_name: str) -> tuple[list[int], dict[str, dict]]:
"""Return the exceptions list version tuple and a mapping of
exceptions id->name loaded from a JSON file
from https://github.com/spdx/license-list-data
Expand Down
4 changes: 2 additions & 2 deletions src/reuse/_lint_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pathlib import Path
from typing import IO

from ._util import PathType, is_relative_to
from ._util import PathType
from .lint import format_lines_subset
from .project import Project
from .report import ProjectSubsetReport
Expand Down Expand Up @@ -43,7 +43,7 @@ def run(args: Namespace, project: Project, out: IO[str] = sys.stdout) -> int:
"""List all non-compliant files from specified file list."""
subset_files = {Path(file_) for file_ in args.files}
for file_ in subset_files:
if not is_relative_to(file_.resolve(), project.root.resolve()):
if not file_.resolve().is_relative_to(project.root.resolve()):
args.parser.error(
_("'{file}' is not inside of '{root}'").format(
file=file_, root=project.root
Expand Down
8 changes: 4 additions & 4 deletions src/reuse/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import warnings
from gettext import gettext as _
from pathlib import Path
from typing import IO, Callable, List, Optional, Type, cast
from typing import IO, Callable, Optional, Type, cast

from . import (
__REUSE_version__,
Expand Down Expand Up @@ -219,7 +219,7 @@ def add_command( # pylint: disable=too-many-arguments,redefined-builtin
formatter_class: Optional[Type[argparse.HelpFormatter]] = None,
description: Optional[str] = None,
help: Optional[str] = None,
aliases: Optional[List[str]] = None,
aliases: Optional[list[str]] = None,
) -> None:
"""Add a subparser for a command."""
if formatter_class is None:
Expand All @@ -236,10 +236,10 @@ def add_command( # pylint: disable=too-many-arguments,redefined-builtin
subparser.set_defaults(parser=subparser)


def main(args: Optional[List[str]] = None, out: IO[str] = sys.stdout) -> int:
def main(args: Optional[list[str]] = None, out: IO[str] = sys.stdout) -> int:
"""Main entry function."""
if args is None:
args = cast(List[str], sys.argv[1:])
args = cast(list[str], sys.argv[1:])

main_parser = parser()
parsed_args = main_parser.parse_args(args)
Expand Down
Loading

0 comments on commit 8615ea7

Please sign in to comment.