Skip to content

Commit

Permalink
Drop support for Python 3.6 and 3.7 (adbar#134)
Browse files Browse the repository at this point in the history
* Drop support for Python 3.6 and 3.7

Python 3.7 is end-of-life for a year now and Python 3.6 even longer, so
let's drop support for them to not limit the use of Python language
features to one supported by those outdated Python versions.

* Remove conditional imports for old Python versions
  • Loading branch information
Dunedan authored Jun 6, 2024
1 parent 6860df6 commit 5f4fa16
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 47 deletions.
13 changes: 0 additions & 13 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ jobs:
os: [ubuntu-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13-dev']
include:
# custom tests
# other OS version necessary
- os: ubuntu-20.04
python-version: '3.6'
- os: ubuntu-20.04
python-version: '3.7'
# common versions on MacOS
- os: macos-latest
python-version: '3.10'
Expand Down Expand Up @@ -62,27 +56,20 @@ jobs:
- uses: actions/checkout@v4

- name: Install dependencies
if: matrix.python-version != '3.6' && matrix.python-version != '3.7'
run: pip install -r requirements-dev.txt

- name: Install dependencies (pytest)
run: python -m pip install --upgrade pytest pytest-cov

# tests
- name: Lint with flake8
if: matrix.python-version != '3.6' && matrix.python-version != '3.7'
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Code format with black
if: matrix.python-version != '3.6' && matrix.python-version != '3.7'
run: black --check --diff simplemma training tests

- name: Type checking with mypy
if: matrix.python-version != '3.6' && matrix.python-version != '3.7'
run: mypy -p simplemma -p training -p tests

- name: Test with pytest
Expand Down
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def get_version(package):
setup(
author="Adrien Barbaresi",
author_email="barbaresi@bbaw.de",
python_requires=">=3.6",
python_requires=">=3.8",
classifiers=[ # https://pypi.org/classifiers/
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
Expand Down Expand Up @@ -71,8 +71,6 @@ def get_version(package):
"Natural Language :: Ukrainian",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand Down
8 changes: 1 addition & 7 deletions simplemma/strategies/dictionaries/dictionary_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,11 @@

import lzma
import pickle
import sys
from abc import abstractmethod
from functools import lru_cache
from os import listdir, path
from pathlib import Path
from typing import ByteString, Dict

if sys.version_info >= (3, 8):
from typing import Protocol
else:
from typing_extensions import Protocol
from typing import ByteString, Dict, Protocol

DATA_FOLDER = str(Path(__file__).parent / "data")
SUPPORTED_LANGUAGES = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
`LemmatizationFallbackStrategy` are used as a fallback strategy when a token's lemma cannot be determined using other lemmatization strategies.
"""

import sys
from abc import abstractmethod

if sys.version_info >= (3, 8):
from typing import Protocol
else:
from typing_extensions import Protocol
from typing import Protocol


class LemmatizationFallbackStrategy(Protocol):
Expand Down
8 changes: 1 addition & 7 deletions simplemma/strategies/lemmatization_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@
This file defines the `LemmatizationStrategy` protocl class, which all lemmatization strategies should extend to be usable by the Simplemma library.
"""

import sys
from abc import abstractmethod
from typing import Optional

if sys.version_info >= (3, 8):
from typing import Protocol
else:
from typing_extensions import Protocol
from typing import Optional, Protocol


class LemmatizationStrategy(Protocol):
Expand Down
8 changes: 1 addition & 7 deletions simplemma/token_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,12 @@
"""

import re
import sys
from abc import ABC, abstractmethod
from collections import Counter
from typing import Iterable, List
from typing import Iterable, List, Protocol

from .tokenizer import RegexTokenizer, Tokenizer

if sys.version_info >= (3, 8):
from typing import Protocol
else:
from typing_extensions import Protocol


SPLIT_INPUT = re.compile(r"[^\W\d_]{3,}")
RELAXED_SPLIT_INPUT = re.compile(r"[\w-]{3,}")
Expand Down
6 changes: 1 addition & 5 deletions simplemma/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@
"""

import re
import sys
from abc import abstractmethod
from typing import Iterator, List, Pattern

if sys.version_info >= (3, 8):
from typing import Protocol
else:
from typing_extensions import Protocol
from typing import Protocol

TOKREGEX = re.compile(
r"(?:"
Expand Down

0 comments on commit 5f4fa16

Please sign in to comment.