Skip to content

Commit

Permalink
Update supported python versions: add 3.12 & remove 3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
ayalash committed Sep 7, 2024
1 parent bf3a70d commit dffe10e
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 19 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ on:

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import os
import sys
import pkg_resources
from importlib.metadata import distribution

nitpicky = True

Expand Down Expand Up @@ -57,7 +57,7 @@
#
# The short X.Y version.

version = release = pkg_resources.get_distribution('slash').version
version = release = distribution("slash").version

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ build-backend = "hatchling.build"
name = "slash"
description = "A Modern Testing Framework for Large-scale Projects"
readme = "README.md"
requires-python = ">=3.7"
requires-python = ">=3.8"
license = { text = "BSD 3-Clause License" }

classifiers = [
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dependencies = [
"arrow",
Expand Down Expand Up @@ -62,8 +62,8 @@ testing = [
"pytest-cov",
"pytest-timeout",
"pyforge",
"astroid~=2.15.5",
"pylint~=2.17.4",
"astroid>=3.0",
"pylint>=3.0",
]
doc = [
"alabaster",
Expand Down
12 changes: 8 additions & 4 deletions slash/__version__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import pkg_resources
import importlib.metadata

get_distribution = importlib.metadata.distribution

__version__ = get_distribution("slash").version

__version__ = pkg_resources.get_distribution('slash').version

def get_backslash_client_version():
try:
return pkg_resources.get_distribution('backslash').version
except pkg_resources.DistributionNotFound:
return get_distribution("backslash").version
except importlib.metadata.PackageNotFoundError:
return None


__backslash_version__ = get_backslash_client_version()
2 changes: 2 additions & 0 deletions slash/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ def _create_log_file_handler(self, log_path, bubble=False, filter=_slash_logs_fi
handler_class = logbook.GZIPCompressionHandler
elif config.root.log.compression.algorithm == "brotli":
handler_class = logbook.BrotliCompressionHandler
else:
raise InvalidConfiguraion(f"Use unsupported compression algorithm: {config.root.log.compression.algorithm}")
elif use_rotation:
kwargs.update({"max_size": 4*1024**2, "backup_count": 1})
handler_class = logbook.RotatingFileHandler
Expand Down
4 changes: 2 additions & 2 deletions slash/plugins/builtin/notifications.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import importlib.resources
from ..interface import PluginInterface
from ... import hooks
from ...conf import config
Expand All @@ -9,7 +10,6 @@
from email.mime.text import MIMEText
from vintage import warn_deprecation
import datetime
from pkg_resources import resource_string
import requests
import slash
import smtplib
Expand Down Expand Up @@ -70,7 +70,7 @@ def get_short_message(self):
def _get_html_template(self):
returned = self._email_template
if returned is None:
source = resource_string('slash.plugins.builtin', 'email_template.j2').decode('utf-8')
source = importlib.resources.files("slash.plugins.builtin").joinpath("email_template.j2").read_bytes().decode("utf-8")
returned = type(self)._email_template = jinja2.Template(source)
return returned

Expand Down
5 changes: 3 additions & 2 deletions slash/site.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import os
import sys
import importlib.metadata

import requests

from .conf import config


def load(thing=None, working_directory=None):
"""
Loads site files (customization files) from various locations.
Expand Down Expand Up @@ -54,8 +56,7 @@ def _load_environment():
load(loaded_url_or_file)

def _load_entry_points():
import pkg_resources
for customize_function_loader in pkg_resources.iter_entry_points("slash.site.customize"): # pylint: disable=no-member
for customize_function_loader in importlib.metadata.entry_points(group="slash.site.customize"):
func = customize_function_loader.load()
func()

Expand Down
6 changes: 3 additions & 3 deletions tests/test_site_customization.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# pylint: disable=global-statement,global-variable-not-assigned
import importlib.metadata
from .utils import TestCase
import os
import sys
Expand All @@ -9,7 +10,6 @@
import munch
from slash.frontend import slash_run
import requests
import pkg_resources


class SlashRunSiteCustomizationTest(TestCase):
Expand Down Expand Up @@ -89,9 +89,9 @@ def test_customize_via_url(self):
self.assert_customization_loaded()

def test_customize_via_pkgutil_entry_point(self):
self.forge.replace(pkg_resources, "iter_entry_points")
self.forge.replace(importlib.metadata, "entry_points")
entry_point = self.forge.create_wildcard_mock()
pkg_resources.iter_entry_points("slash.site.customize").and_return(iter([entry_point]))
importlib.metadata.entry_points(group="slash.site.customize").and_return(iter([entry_point])) # pylint: disable=no-member
unused = self.get_customization_source() # expect a single customization # pylint: disable=unused-variable
entry_point.load().and_return(_apply_customization)
self.forge.replay()
Expand Down

0 comments on commit dffe10e

Please sign in to comment.