Skip to content

Commit

Permalink
Merge pull request #85 from hugovk/develop
Browse files Browse the repository at this point in the history
Add support for Python 3.11 and drop EOL 3.5-3.7
  • Loading branch information
wolph authored Sep 13, 2023
2 parents 98d143e + aa0a674 commit 21bb3df
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 37 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@ on:
pull_request:
branches: [ develop ]

env:
FORCE_COLOR: 1

jobs:
# Run os specific tests on the slower OS X/Windows machines
windows_osx:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10']
python-version: ['3.8', '3.9', '3.10', '3.11']
os: ['macos-latest', 'windows-latest']

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
Expand All @@ -38,12 +41,12 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10']
python-version: ['3.8', '3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Start Redis
uses: supercharge/redis-github-action@1.4.0
uses: supercharge/redis-github-action@1.7.0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ environment:
global:
PYTHON: "C:\\Python38-x64\\python.exe"
matrix:
- TOXENV: py36
- TOXENV: py37
- TOXENV: py38
- TOXENV: py39
- TOXENV: py310
- TOXENV: py311

install:
- "%PYTHON% -m pip install -U tox setuptools wheel"
Expand Down
9 changes: 4 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# Documentation build configuration file, created by
# sphinx-quickstart on Thu Feb 27 20:00:23 2014.
Expand Down Expand Up @@ -57,7 +56,7 @@

# General information about the project.
project = metadata.__package_name__.replace('-', ' ').capitalize()
copyright = u'%s, <a href="http://wol.ph/">%s</a>' % (
copyright = '{}, <a href="http://wol.ph/">{}</a>'.format(
datetime.date.today().year,
metadata.__author__,
)
Expand Down Expand Up @@ -213,7 +212,7 @@
latex_documents = [(
'index',
'%s.tex' % metadata.__package_name__,
u'%s Documentation' % metadata.__package_name__.replace('-', ' ').capitalize(),
'%s Documentation' % metadata.__package_name__.replace('-', ' ').capitalize(),
metadata.__author__,
'manual',
)]
Expand Down Expand Up @@ -246,7 +245,7 @@
man_pages = [(
'index',
metadata.__package_name__,
u'%s Documentation' % metadata.__package_name__.replace('-', ' ').capitalize(),
'%s Documentation' % metadata.__package_name__.replace('-', ' ').capitalize(),
[metadata.__author__],
1,
)]
Expand All @@ -263,7 +262,7 @@
texinfo_documents = [(
'index',
metadata.__package_name__,
u'%s Documentation' % metadata.__package_name__.replace('-', ' ').capitalize(),
'%s Documentation' % metadata.__package_name__.replace('-', ' ').capitalize(),
metadata.__author__,
metadata.__package_name__,
metadata.__description__,
Expand Down
2 changes: 1 addition & 1 deletion portalocker/portalocker.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def unlock(file_: typing.IO):
finally:
if savepos:
file_.seek(savepos)
except IOError as exc:
except OSError as exc:
raise exceptions.LockException(
exceptions.LockException.LOCK_FAILED, exc.strerror,
fh=file_
Expand Down
6 changes: 3 additions & 3 deletions portalocker/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ def __init__(
for key, value in self.DEFAULT_REDIS_KWARGS.items():
self.redis_kwargs.setdefault(key, value)

super(RedisLock, self).__init__(timeout=timeout,
check_interval=check_interval,
fail_when_locked=fail_when_locked)
super().__init__(timeout=timeout,
check_interval=check_interval,
fail_when_locked=fail_when_locked)

def get_connection(self) -> client.Redis:
if not self.connection:
Expand Down
10 changes: 5 additions & 5 deletions portalocker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ def __init__(
self, filename, mode='a', timeout=DEFAULT_TIMEOUT,
check_interval=DEFAULT_CHECK_INTERVAL, fail_when_locked=False,
flags=LOCK_METHOD):
super(RLock, self).__init__(filename, mode, timeout, check_interval,
fail_when_locked, flags)
super().__init__(filename, mode, timeout, check_interval,
fail_when_locked, flags)
self._acquire_count = 0

def acquire(
Expand All @@ -330,8 +330,8 @@ def acquire(
if self._acquire_count >= 1:
fh = self.fh
else:
fh = super(RLock, self).acquire(timeout, check_interval,
fail_when_locked)
fh = super().acquire(timeout, check_interval,
fail_when_locked)
self._acquire_count += 1
assert fh
return fh
Expand All @@ -342,7 +342,7 @@ def release(self):
"Cannot release more times than acquired")

if self._acquire_count == 1:
super(RLock, self).release()
super().release()
self._acquire_count -= 1


Expand Down
11 changes: 4 additions & 7 deletions portalocker_tests/tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from __future__ import print_function
from __future__ import with_statement

import os
import dataclasses
import multiprocessing
Expand Down Expand Up @@ -173,12 +170,12 @@ def test_exlusive(tmpfile):
with open(tmpfile, 'w') as fh:
fh.write('spam and eggs')

fh = open(tmpfile, 'r')
fh = open(tmpfile)
portalocker.lock(fh, portalocker.LOCK_EX | portalocker.LOCK_NB)

# Make sure we can't read the locked file
with pytest.raises(portalocker.LockException):
with open(tmpfile, 'r') as fh2:
with open(tmpfile) as fh2:
portalocker.lock(fh2, portalocker.LOCK_EX | portalocker.LOCK_NB)
fh2.read()

Expand All @@ -197,11 +194,11 @@ def test_shared(tmpfile):
with open(tmpfile, 'w') as fh:
fh.write('spam and eggs')

f = open(tmpfile, 'r')
f = open(tmpfile)
portalocker.lock(f, portalocker.LOCK_SH | portalocker.LOCK_NB)

# Make sure we can read the locked file
with open(tmpfile, 'r') as fh2:
with open(tmpfile) as fh2:
portalocker.lock(fh2, portalocker.LOCK_SH | portalocker.LOCK_NB)
assert fh2.read() == 'spam and eggs'

Expand Down
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[metadata]
description_file = README.rst

[bdist_wheel]
universal = 1

[flake8]
ignore =
W391,E303,W503
Expand Down
8 changes: 2 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function

import os
import re
import typing
Expand Down Expand Up @@ -87,16 +85,14 @@ def run(self):
classifiers=[
'Intended Audience :: Developers',
'Programming Language :: Python',
'Programming Language :: Python :: 3.5',
'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',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
],
python_requires='>=3.5',
python_requires='>=3.8',
keywords='locking, locks, with statement, windows, linux, unix',
author=about['__author__'],
author_email=about['__email__'],
Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ envlist = py38, py39, py310, py311, pypy3, flake8, docs
skip_missing_interpreters = True

[testenv]
pass_env =
FORCE_COLOR
basepython =
py38: python3.8
py39: python3.9
Expand Down

0 comments on commit 21bb3df

Please sign in to comment.