Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Python 3.13 and drop EOL 3.7-3.8 #65

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ jobs:
fail-fast: false
matrix:
python-version:
["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "pypy-3.8"]
["pypy3.10", "3.9", "3.10", "3.11", "3.12", "3.13"]
os: [ubuntu-latest, macos-latest, windows-latest]
exclude:
- os: macos-latest
python-version: "pypy-3.8"
python-version: "pypy3.10"
- os: windows-latest
python-version: "pypy-3.8"
python-version: "pypy3.10"

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ https://pytablewriter.rtfd.io/en/latest/pages/examples/index.html

Dependencies
============
- Python 3.7+
- Python 3.9+
- `Python package dependencies (automatically installed) <https://github.com/thombashi/pytablewriter/network/dependencies>`__


Expand Down
2 changes: 1 addition & 1 deletion docs/pages/introduction/dependencies.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Dependencies
============
- Python 3.7+
- Python 3.9+
- `Python package dependencies (automatically installed) <https://github.com/thombashi/pytablewriter/network/dependencies>`__


Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ exclude = '''
| setup.py
'''
line-length = 100
target-version = ['py37', 'py38', 'py39', 'py310', 'py311', 'py312']
target-version = ['py39', 'py310', 'py311', 'py312', 'py313']

[tool.isort]
include_trailing_comma = true
Expand Down Expand Up @@ -72,7 +72,7 @@ show_missing = true

[tool.mypy]
ignore_missing_imports = true
python_version = 3.7
python_version = 3.9

pretty = true

Expand Down
6 changes: 3 additions & 3 deletions pytablewriter/_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import os
from itertools import chain
from typing import Any, List
from typing import Any

import typepy

Expand Down Expand Up @@ -167,7 +167,7 @@ def create_from_format_name(cls, format_name: str, **kwargs: Any) -> AbstractTab
)

@classmethod
def get_format_names(cls) -> List[str]:
def get_format_names(cls) -> list[str]:
"""
:return: Available format names.
:rtype: list
Expand Down Expand Up @@ -228,7 +228,7 @@ def get_format_names(cls) -> List[str]:
return sorted(list(set(chain(*(table_format.names for table_format in TableFormat)))))

@classmethod
def get_extensions(cls) -> List[str]:
def get_extensions(cls) -> list[str]:
"""
:return: Available file extensions.
:rtype: list
Expand Down
4 changes: 2 additions & 2 deletions pytablewriter/_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from datetime import datetime
from enum import Enum
from typing import Any, Optional, Type
from typing import Any, Optional

import dataproperty
from pathvalidate import replace_symbol
Expand Down Expand Up @@ -60,7 +60,7 @@ def dumps_tabledata(value: TableData, format_name: str = "rst_grid_table", **kwa


def normalize_enum(
value: Any, enum_class: Type[Enum], validate: bool = True, default: Optional[Enum] = None
value: Any, enum_class: type[Enum], validate: bool = True, default: Optional[Enum] = None
) -> Any:
if value is None:
return default
Expand Down
4 changes: 2 additions & 2 deletions pytablewriter/_logger/_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.. codeauthor:: Tsuyoshi Hombashi <[email protected]>
"""

from typing import TYPE_CHECKING, List
from typing import TYPE_CHECKING

import dataproperty
from mbstrdecoder import MultiByteStrDecoder
Expand Down Expand Up @@ -102,7 +102,7 @@ def __get_table_name_message(self) -> str:

return f"table-name='{table_name}'"

def __get_extra_log_entry_list(self) -> List[str]:
def __get_extra_log_entry_list(self) -> list[str]:
if self.__writer._iter_count is None:
return []

Expand Down
9 changes: 5 additions & 4 deletions pytablewriter/_table_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"""

import enum
from typing import List, Optional, Sequence
from collections.abc import Sequence
from typing import Optional

from .writer import (
AbstractTableWriter,
Expand Down Expand Up @@ -252,7 +253,7 @@ class TableFormat(enum.Enum):
)

@property
def names(self) -> List[str]:
def names(self) -> list[str]:
"""
List[str]: Names associated with the table format.
"""
Expand All @@ -276,7 +277,7 @@ def format_attribute(self) -> int:
return self.__format_attribute

@property
def file_extensions(self) -> List[str]:
def file_extensions(self) -> list[str]:
"""
List[str]: File extensions associated with the table format.
"""
Expand All @@ -296,7 +297,7 @@ def __init__(
self.__file_extensions = list(file_extensions)

@classmethod
def find_all_attr(cls, format_attribute: int) -> List["TableFormat"]:
def find_all_attr(cls, format_attribute: int) -> list["TableFormat"]:
"""Searching table formats that have specific attributes.

Args:
Expand Down
2 changes: 1 addition & 1 deletion pytablewriter/sanitizer/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import abc
import re
from typing import Pattern
from re import Pattern

from pathvalidate.error import ErrorReason, ValidationError
from typepy import is_null_string
Expand Down
5 changes: 3 additions & 2 deletions pytablewriter/sanitizer/_elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"""

import re
from typing import ClassVar, List, Pattern
from re import Pattern
from typing import ClassVar

from ._base import VarNameSanitizer

Expand All @@ -15,7 +16,7 @@ class ElasticsearchIndexNameSanitizer(VarNameSanitizer):
__RE_INVALID_INDEX_NAME_HEAD: ClassVar[Pattern[str]] = re.compile("^[_]+")

@property
def reserved_keywords(self) -> List[str]:
def reserved_keywords(self) -> list[str]:
return []

@property
Expand Down
3 changes: 1 addition & 2 deletions pytablewriter/sanitizer/_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
"""

import abc
from typing import List

from pathvalidate import validate_pathtype


class NameSanitizer(metaclass=abc.ABCMeta):
@abc.abstractproperty
def reserved_keywords(self) -> List[str]: # pragma: no cover
def reserved_keywords(self) -> list[str]: # pragma: no cover
pass

@abc.abstractmethod
Expand Down
4 changes: 2 additions & 2 deletions pytablewriter/sanitizer/_javascript.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

import re
from typing import List, Pattern
from re import Pattern

from ._base import VarNameSanitizer

Expand Down Expand Up @@ -78,7 +78,7 @@ class JavaScriptVarNameSanitizer(VarNameSanitizer):
__RE_INVALID_VAR_NAME_HEAD = re.compile("^[^a-zA-Z$]+")

@property
def reserved_keywords(self) -> List[str]:
def reserved_keywords(self) -> list[str]:
return (
self.__JS_RESERVED_KEYWORDS_ES6
+ self.__JS_RESERVED_KEYWORDS_FUTURE
Expand Down
4 changes: 2 additions & 2 deletions pytablewriter/sanitizer/_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

import re
from typing import List, Pattern
from re import Pattern

from ._base import VarNameSanitizer

Expand Down Expand Up @@ -55,7 +55,7 @@ class PythonVarNameSanitizer(VarNameSanitizer):
__RE_INVALID_VAR_NAME_HEAD = re.compile("^[^a-zA-Z]+")

@property
def reserved_keywords(self) -> List[str]:
def reserved_keywords(self) -> list[str]:
return self.__PYTHON_RESERVED_KEYWORDS + self.__PYTHON_BUILTIN_CONSTANTS

@property
Expand Down
4 changes: 2 additions & 2 deletions pytablewriter/style/_style.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import warnings
from enum import Enum, unique
from typing import Any, Dict, Optional, Union
from typing import Any, Optional, Union

from dataproperty import Align
from tcolorpy import Color
Expand Down Expand Up @@ -45,7 +45,7 @@ def __init__(self, code: int, string: str) -> None:
self.__align_string = string


_s_to_ts: Dict[str, ThousandSeparator] = {
_s_to_ts: dict[str, ThousandSeparator] = {
"": ThousandSeparator.NONE,
",": ThousandSeparator.COMMA,
" ": ThousandSeparator.SPACE,
Expand Down
10 changes: 5 additions & 5 deletions pytablewriter/style/_styler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import re
from typing import TYPE_CHECKING, Any, Dict, Optional
from typing import TYPE_CHECKING, Any, Optional

from dataproperty import Align
from tcolorpy import Color, tcolor
Expand All @@ -13,7 +13,7 @@
from ..writer._table_writer import AbstractTableWriter


_align_char_mapping: Dict[Align, str] = {
_align_char_mapping: dict[Align, str] = {
Align.AUTO: "<",
Align.LEFT: "<",
Align.RIGHT: ">",
Expand Down Expand Up @@ -49,7 +49,7 @@ def apply_align(self, value: str, style: Style) -> str:
def apply_terminal_style(self, value: str, style: Style) -> str:
return value

def _get_font_size_map(self) -> Dict[FontSize, str]:
def _get_font_size_map(self) -> dict[FontSize, str]:
return {}


Expand Down Expand Up @@ -101,7 +101,7 @@ def apply(self, value: str, style: Style) -> str:


class HtmlStyler(TextStyler):
def _get_font_size_map(self) -> Dict[FontSize, str]:
def _get_font_size_map(self) -> dict[FontSize, str]:
return {
FontSize.TINY: "font-size:x-small",
FontSize.SMALL: "font-size:small",
Expand Down Expand Up @@ -163,7 +163,7 @@ def __apply_color(self, value: str, style: Style) -> str:

return value

def _get_font_size_map(self) -> Dict[FontSize, str]:
def _get_font_size_map(self) -> dict[FontSize, str]:
return {
FontSize.TINY: r"\tiny",
FontSize.SMALL: r"\small",
Expand Down
7 changes: 4 additions & 3 deletions pytablewriter/style/_theme.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import importlib
import pkgutil
import re
from typing import Any, Dict, NamedTuple, Optional, Sequence
from collections.abc import Sequence
from typing import Any, NamedTuple, Optional

from .._logger import logger
from ..style import Cell, Style
Expand Down Expand Up @@ -45,7 +46,7 @@ def list_themes() -> Sequence[str]:
return list(load_ptw_plugins())


def load_ptw_plugins() -> Dict[str, Theme]:
def load_ptw_plugins() -> dict[str, Theme]:
plugin_regexp = re.compile(
rf"^{PLUGIN_NAME_PEFIX}[_-].+[_-]{PLUGIN_NAME_SUFFIX}", re.IGNORECASE
)
Expand All @@ -58,7 +59,7 @@ def load_ptw_plugins() -> Dict[str, Theme]:

logger.debug(f"discovered_plugins: {list(discovered_plugins)}")

themes: Dict[str, Theme] = {}
themes: dict[str, Theme] = {}
for theme, plugin in discovered_plugins.items():
style_filter = plugin.style_filter if hasattr(plugin, "style_filter") else None
col_sep_style_filter = (
Expand Down
9 changes: 5 additions & 4 deletions pytablewriter/writer/_elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"""

import copy
from typing import Any, Dict, Generator
from collections.abc import Generator
from typing import Any

import dataproperty
from dataproperty import ColumnDataProperty
Expand All @@ -14,8 +15,8 @@
from ._table_writer import AbstractTableWriter


DataType = Dict[str, str]
Properties = Dict[str, DataType]
DataType = dict[str, str]
Properties = dict[str, DataType]


def _get_es_datatype(column_dp: ColumnDataProperty) -> DataType:
Expand Down Expand Up @@ -148,7 +149,7 @@ def __init__(self, **kwargs: Any) -> None:
def write_null_line(self) -> None:
pass

def _get_mappings(self) -> Dict[str, Dict[str, Dict[str, Properties]]]:
def _get_mappings(self) -> dict[str, dict[str, dict[str, Properties]]]:
properties: Properties = {}

for header, column_dp in zip(self.headers, self._column_dp_list):
Expand Down
Loading
Loading