diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 7cb780d..71209cc 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -6,6 +6,9 @@ on: pull_request: branches: [ develop ] +env: + FORCE_COLOR: 1 + jobs: # Run os specific tests on the slower OS X/Windows machines windows_osx: @@ -13,11 +16,11 @@ jobs: 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: @@ -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: diff --git a/appveyor.yml b/appveyor.yml index 8ad9373..0574689 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -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" diff --git a/docs/conf.py b/docs/conf.py index 07e4caf..761d7f3 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Documentation build configuration file, created by # sphinx-quickstart on Thu Feb 27 20:00:23 2014. @@ -57,7 +56,7 @@ # General information about the project. project = metadata.__package_name__.replace('-', ' ').capitalize() -copyright = u'%s, %s' % ( +copyright = '{}, {}'.format( datetime.date.today().year, metadata.__author__, ) @@ -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', )] @@ -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, )] @@ -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__, diff --git a/portalocker/portalocker.py b/portalocker/portalocker.py index 72260a7..b1e0964 100644 --- a/portalocker/portalocker.py +++ b/portalocker/portalocker.py @@ -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_ diff --git a/portalocker/redis.py b/portalocker/redis.py index 08dbd4a..26c337d 100644 --- a/portalocker/redis.py +++ b/portalocker/redis.py @@ -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: diff --git a/portalocker/utils.py b/portalocker/utils.py index b02773d..5bf4cab 100644 --- a/portalocker/utils.py +++ b/portalocker/utils.py @@ -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( @@ -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 @@ -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 diff --git a/portalocker_tests/tests.py b/portalocker_tests/tests.py index 7a00405..7c75239 100644 --- a/portalocker_tests/tests.py +++ b/portalocker_tests/tests.py @@ -1,6 +1,3 @@ -from __future__ import print_function -from __future__ import with_statement - import os import dataclasses import multiprocessing @@ -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() @@ -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' diff --git a/setup.cfg b/setup.cfg index 9960540..c9bc65e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,9 +1,6 @@ [metadata] description_file = README.rst -[bdist_wheel] -universal = 1 - [flake8] ignore = W391,E303,W503 diff --git a/setup.py b/setup.py index 5c7bfd6..796936e 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,3 @@ -from __future__ import print_function - import os import re import typing @@ -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__'], diff --git a/tox.ini b/tox.ini index b9960b0..6c1dfa6 100644 --- a/tox.ini +++ b/tox.ini @@ -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