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

Remove 3.7 and update pre-commit to 3.8 #2856

Merged
merged 1 commit into from
Oct 9, 2023
Merged
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
1 change: 0 additions & 1 deletion .github/workflows/docker/shared.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ PYTHON_VERSIONS=(
cp310-cp310
cp39-cp39
cp38-cp38
cp37-cp37m
)
13 changes: 6 additions & 7 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
python: [3.7, 3.8, 3.9, "3.10", 3.11]
python: [3.8, 3.9, "3.10", 3.11]
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
runs-on: windows-latest
strategy:
matrix:
python: [3.7, 3.8, 3.9, "3.10", 3.11]
python: [3.8, 3.9, "3.10", 3.11]
wordsize: [64]
steps:
- name: Checkout
Expand Down Expand Up @@ -140,7 +140,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
python: [3.7, 3.8, 3.9, "3.10", 3.11]
python: [3.8, 3.9, "3.10", 3.11]
steps:
- name: Download wheels
uses: actions/download-artifact@v2
Expand All @@ -162,7 +162,7 @@ jobs:
runs-on: windows-latest
strategy:
matrix:
python: [3.7, 3.8, 3.9, "3.10", 3.11]
python: [3.8, 3.9, "3.10", 3.11]
wordsize: [64]
steps:
- name: Download wheels
Expand All @@ -186,10 +186,9 @@ jobs:
needs: ['manylinux']
strategy:
matrix:
python: [3.7, 3.8, 3.9, "3.10", 3.11]
python: [3.8, 3.9, "3.10", 3.11]
include:
- python: 3.7
wheel: cp37

- python: 3.8
wheel: cp38
- python: 3.9
Expand Down
16 changes: 8 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.5.0
hooks:
- id: check-merge-conflict
- id: debug-statements
Expand All @@ -18,29 +18,29 @@ repos:
exclude: dev-tools|examples
verbose: true
- repo: https://github.com/asottile/reorder_python_imports
rev: v3.9.0
rev: v3.12.0
hooks:
- id: reorder-python-imports
args: [--application-directories=python,
--unclassifiable-application-module=_tskit]
- repo: https://github.com/asottile/pyupgrade
rev: v3.2.2
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py3-plus, --py37-plus]
args: [--py3-plus, --py38-plus]
- repo: https://github.com/psf/black
rev: 22.10.0
rev: 23.9.1
hooks:
- id: black
language_version: python3
- repo: https://github.com/pycqa/flake8
rev: 5.0.4
rev: 6.1.0
hooks:
- id: flake8
args: [--config=python/.flake8]
additional_dependencies: ["flake8-bugbear==22.10.27", "flake8-builtins==2.0.1"]
additional_dependencies: ["flake8-bugbear==23.9.16", "flake8-builtins==2.1.0"]
- repo: https://github.com/asottile/blacken-docs
rev: v1.12.1
rev: 1.16.0
hooks:
- id: blacken-docs
args: [--skip-errors]
Expand Down
8 changes: 4 additions & 4 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ an overview of how to contribute a new feature to `tskit`.
### Requirements

To develop the Python code you will need a working C compiler and a
development installation of Python (>= 3.7). On Debian/Ubuntu we can install these
development installation of Python (>= 3.8). On Debian/Ubuntu we can install these
with:

```bash
Expand Down Expand Up @@ -429,7 +429,7 @@ $ make

If this has completed successfully you should see a file `_tskit.cpython-XXXXXX.so`
in the current directory (the suffix depends on your platform and Python version;
with Python 3.7 on Linux it's `_tskit.cpython-37m-x86_64-linux-gnu.so`).
with Python 3.11 on Linux it's `_tskit.cpython-311-x86_64-linux-gnu.so`).

To make sure that your development environment is working, run some
{ref}`tests <sec_development_python_tests>`.
Expand Down Expand Up @@ -1050,10 +1050,10 @@ For instance:

```bash
> git commit -a -m 'fixed all the things'
/usr/bin/env: ‘python3.7’: No such file or directory
/usr/bin/env: ‘python3.8’: No such file or directory
```

What the heck? Why is this even looking for python3.7?
What the heck? Why is this even looking for python3.8?
This is because of the "pre-commit hook", mentioned above.
As above, you can proceed by just appending `--no-verify`:

Expand Down
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ so it may already be installed if you use such software.

## Requirements

Tskit requires Python 3.7+. There are no external C library dependencies. Python
Tskit requires Python 3.8+. There are no external C library dependencies. Python
dependencies are installed automatically by `pip` or `conda`.

(sec_installation_conda)=
Expand Down
4 changes: 4 additions & 0 deletions python/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
[0.5.6] - 2023-XX-XX
--------------------

**Breaking Changes**

- tskit now requires Python 3.8, as Python 3.7 became end-of-life on 2023-06-27

**Features**

- Tree.trmca now accepts >2 nodes and returns nicer errors
Expand Down
3 changes: 1 addition & 2 deletions python/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ classifiers =
Programming Language :: C
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should add 3.11 here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checked and it was already there - just snipped off this diff.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, my bad

Expand Down Expand Up @@ -46,7 +45,7 @@ platforms =

[options]
packages = tskit
python_requires = >=3.7
python_requires = >=3.8
include_package_data = True
install_requires =
jsonschema>=3.0.0
Expand Down
3 changes: 0 additions & 3 deletions python/tests/simplify.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,6 @@ def flush_edges(self):
return num_edges

def check_state(self):

num_nodes = len(self.A_head)
for j in range(num_nodes):
head = self.A_head[j]
Expand Down Expand Up @@ -771,7 +770,6 @@ def print_state(self):
ts = tskit.load(sys.argv[2])

if class_to_implement == "Simplifier":

samples = list(map(int, sys.argv[3:]))

print("When keep_unary = True:")
Expand Down Expand Up @@ -805,7 +803,6 @@ def print_state(self):
print(tables.mutations)

elif class_to_implement == "AncestorMap":

samples = sys.argv[3]
samples = samples.split(",")
samples = list(map(int, samples))
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_file_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ def test_unsupported_version(self):
# Cannot read current files.
ts.dump(self.temp_file)
# Catch Exception here because h5py throws different exceptions on py2 and py3
with pytest.raises(Exception):
with pytest.raises(Exception): # noqa B017
tskit.load_legacy(self.temp_file)

def test_no_version_number(self):
Expand Down
6 changes: 3 additions & 3 deletions python/tests/test_highlevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def insert_gap(ts, position, length):
return tables.tree_sequence()


@functools.lru_cache()
@functools.lru_cache
def get_gap_examples():
"""
Returns example tree sequences that contain gaps within the list of
Expand Down Expand Up @@ -239,7 +239,7 @@ def get_gap_examples():
return ret


@functools.lru_cache()
@functools.lru_cache
def get_internal_samples_examples():
"""
Returns example tree sequences with internal samples.
Expand Down Expand Up @@ -270,7 +270,7 @@ def get_internal_samples_examples():
return ret


@functools.lru_cache()
@functools.lru_cache
def get_decapitated_examples():
"""
Returns example tree sequences in which the oldest edges have been removed.
Expand Down
3 changes: 0 additions & 3 deletions python/tests/test_ibd.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ def test_empty_in_between(self, ts):


class TestIbdTwoSamplesTwoTrees:

# 2
# | 3
# 1 2 | / \
Expand Down Expand Up @@ -339,15 +338,13 @@ def test_length(self):


class TestIbdUnrelatedSamples:

#
# 2 3
# | |
# 0 1

@tests.cached_example
def ts(self):

nodes = io.StringIO(
"""\
id is_sample time
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_lowlevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4044,7 +4044,7 @@ def test_uninitialised():
]
for cls_name, cls in inspect.getmembers(_tskit):
if (
type(cls) == type
isinstance(cls, type)
and not issubclass(cls, Exception)
and not issubclass(cls, tuple)
):
Expand Down
3 changes: 0 additions & 3 deletions python/tests/test_table_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def test_mutation_parents(self, ts):


class TestDeleteOlderSimpleTree:

# 2.00┊ 4 ┊
# ┊ ┏━┻┓ ┊
# 1.00┊ ┃ 3 ┊
Expand Down Expand Up @@ -357,7 +356,6 @@ def split_edges_definition(ts, time, *, flags=0, population=None, metadata=None)


class TestSplitEdgesSimpleTree:

# 2.00┊ 4 ┊
# ┊ ┏━┻┓ ┊
# 1.00┊ ┃ 3 ┊
Expand Down Expand Up @@ -757,7 +755,6 @@ def test_no_population(self, ts):


class TestDecapitateSimpleTree:

# 2.00┊ 4 ┊
# ┊ ┏━┻┓ ┊
# 1.00┊ ┃ 3 ┊
Expand Down
11 changes: 4 additions & 7 deletions python/tests/test_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -1772,7 +1772,6 @@ def test_keep_rows_data(self):


class TestNodeTable(*common_tests):

columns = [
UInt32Column("flags"),
DoubleColumn("time"),
Expand Down Expand Up @@ -1853,7 +1852,6 @@ def test_add_row_bad_data(self):


class TestEdgeTable(*common_tests):

columns = [
DoubleColumn("left"),
DoubleColumn("right"),
Expand Down Expand Up @@ -3856,13 +3854,13 @@ def check_concordance(d1, d2):
assert set(d1.keys()) == set(d2.keys())
for k1, v1 in d1.items():
v2 = d2[k1]
assert type(v1) == type(v2)
if type(v1) == dict:
assert type(v1) is type(v2)
if type(v1) is dict:
assert set(v1.keys()) == set(v2.keys())
for sk1, sv1 in v1.items():
sv2 = v2[sk1]
assert type(sv1) == type(sv2)
if type(sv1) == np.ndarray:
assert type(sv1) is type(sv2)
if isinstance(sv1, np.ndarray):
assert np.array_equal(sv1, sv2) or (
np.all(tskit.is_unknown_time(sv1))
and np.all(tskit.is_unknown_time(sv2))
Expand Down Expand Up @@ -4172,7 +4170,6 @@ def test_kwargs_only(self):


class TestTableCollectionMetadata:

metadata_schema = metadata.MetadataSchema(
{
"codec": "json",
Expand Down
4 changes: 2 additions & 2 deletions python/tests/test_text_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test_insufficient_cols(self, n_cols):
entry = FamEntry(iid="1")
for field in fields[n_cols:]:
entry.__setattr__(field, None)
with pytest.raises(
with pytest.raises( # noqa B017
Exception
): # Have to be non-specific here as numpy 1.23 changed the exception type
self.get_parsed_fam(entries=[entry])
Expand Down Expand Up @@ -137,7 +137,7 @@ def test_bad_sex_value(self, sex):

def test_empty_sex_value(self):
entries = [FamEntry(iid="1", sex="")]
with pytest.raises(
with pytest.raises( # noqa B017
Exception
): # Have to be non-specific here as numpy 1.23 changed the exception type
self.get_parsed_fam(entries=entries)
Expand Down
2 changes: 1 addition & 1 deletion python/tskit/combinatorics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ def is_symmetrical(self):
# so we should compute a vector of those results up front instead of using
# repeated calls to this function.
# Put an lru_cache on for now as a quick replacement (cuts test time down by 80%)
@functools.lru_cache()
@functools.lru_cache
def num_shapes(n):
"""
The cardinality of the set of unlabelled trees with n leaves,
Expand Down
Loading
Loading