Skip to content

Commit

Permalink
Update pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
benjeffery authored and mergify[bot] committed May 3, 2024
1 parent 1b84b63 commit d32d63f
Show file tree
Hide file tree
Showing 21 changed files with 78 additions and 62 deletions.
8 changes: 4 additions & 4 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.5.0
rev: v4.6.0
hooks:
- id: check-merge-conflict
- id: debug-statements
Expand All @@ -24,17 +24,17 @@ repos:
args: [--application-directories=python,
--unclassifiable-application-module=_tskit]
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
rev: v3.15.2
hooks:
- id: pyupgrade
args: [--py3-plus, --py38-plus]
- repo: https://github.com/psf/black
rev: 23.9.1
rev: 24.4.2
hooks:
- id: black
language_version: python3
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
rev: 7.0.0
hooks:
- id: flake8
args: [--config=python/.flake8]
Expand Down
2 changes: 1 addition & 1 deletion c/tests/test_core.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2019-2021 Tskit Developers
* Copyright (c) 2019-2024 Tskit Developers
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion c/tests/testlib.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2019-2023 Tskit Developers
* Copyright (c) 2019-2024 Tskit Developers
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion c/tskit/core.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2019-2023 Tskit Developers
* Copyright (c) 2019-2024 Tskit Developers
* Copyright (c) 2015-2018 University of Oxford
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
2 changes: 1 addition & 1 deletion c/tskit/core.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2019-2023 Tskit Developers
* Copyright (c) 2019-2024 Tskit Developers
* Copyright (c) 2015-2018 University of Oxford
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
2 changes: 1 addition & 1 deletion python/_tskitmodule.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2019-2023 Tskit Developers
* Copyright (c) 2019-2024 Tskit Developers
* Copyright (c) 2015-2018 University of Oxford
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
9 changes: 5 additions & 4 deletions python/stress_lowlevel.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
"""
Code to stress the low-level API as much as possible to expose
any memory leaks or error handling issues.
"""
import curses
import os
import random
Expand All @@ -13,6 +9,11 @@

import pytest

"""
Code to stress the low-level API as much as possible to expose
any memory leaks or error handling issues.
"""


def main(stdscr):
if len(sys.argv) > 1:
Expand Down
2 changes: 1 addition & 1 deletion python/tests/simplify.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2019-2022 Tskit Developers
# Copyright (c) 2019-2024 Tskit Developers
# Copyright (c) 2015-2018 University of Oxford
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
12 changes: 6 additions & 6 deletions python/tests/test_genotype_matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,9 @@ def update_probabilities(self, site, genotype_state):

for st1 in T:
if st1.tree_node != -1:
normalisation_factor_inner[
st1.tree_node
] = self.compute_normalisation_factor_inner_dict(st1.tree_node)
normalisation_factor_inner[st1.tree_node] = (
self.compute_normalisation_factor_inner_dict(st1.tree_node)
)

for st1 in T:
if st1.tree_node != -1:
Expand Down Expand Up @@ -506,9 +506,9 @@ def process_site(

for st1 in self.T:
if st1.tree_node != -1:
normalisation_factor_inner[
st1.tree_node
] = self.compute_normalisation_factor_inner_dict(st1.tree_node)
normalisation_factor_inner[st1.tree_node] = (
self.compute_normalisation_factor_inner_dict(st1.tree_node)
)

for st1 in self.T:
if st1.tree_node != -1:
Expand Down
7 changes: 4 additions & 3 deletions python/tests/test_ibd.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
"""
Tests of IBD finding algorithms.
"""
import collections
import io
import itertools
Expand All @@ -15,6 +12,10 @@
import tskit
from tests.test_highlevel import get_example_tree_sequences

"""
Tests of IBD finding algorithms.
"""


# ↑ See https://github.com/tskit-dev/tskit/issues/1804 for when
# we can remove this. The example_ts here is intended to be the
Expand Down
4 changes: 2 additions & 2 deletions python/tests/test_intervals.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# MIT License
#
# Copyright (c) 2023 Tskit Developers
# Copyright (C) 2020-2021 University of Oxford
# Copyright (c) 2023-2024 Tskit Developers
# Copyright (C) 2020-2022 University of Oxford
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_lowlevel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2018-2023 Tskit Developers
# Copyright (c) 2018-2024 Tskit Developers
# Copyright (c) 2015-2018 University of Oxford
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_table_transforms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2022 Tskit Developers
# Copyright (c) 2022-2024 Tskit Developers
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
22 changes: 15 additions & 7 deletions python/tests/test_tables.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2018-2023 Tskit Developers
# Copyright (c) 2018-2024 Tskit Developers
# Copyright (c) 2017 University of Oxford
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -102,12 +102,20 @@ def make_transposed_input_data(self, num_rows):
cols = self.make_input_data(num_rows)
return [
{
col: data[j]
if len(data) == num_rows
else (
bytes(data[cols[f"{col}_offset"][j] : cols[f"{col}_offset"][j + 1]])
if "metadata" in col
else data[cols[f"{col}_offset"][j] : cols[f"{col}_offset"][j + 1]]
col: (
data[j]
if len(data) == num_rows
else (
bytes(
data[
cols[f"{col}_offset"][j] : cols[f"{col}_offset"][j + 1]
]
)
if "metadata" in col
else data[
cols[f"{col}_offset"][j] : cols[f"{col}_offset"][j + 1]
]
)
)
for col, data in cols.items()
if "offset" not in col
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_text_formats.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2021-2022 Tskit Developers
# Copyright (c) 2021-2024 Tskit Developers
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion python/tskit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2018-2023 Tskit Developers
# Copyright (c) 2018-2024 Tskit Developers
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion python/tskit/combinatorics.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# MIT License
#
# Copyright (c) 2020-2022 Tskit Developers
# Copyright (c) 2020-2024 Tskit Developers
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
26 changes: 13 additions & 13 deletions python/tskit/metadata.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2020-2023 Tskit Developers
# Copyright (c) 2020-2024 Tskit Developers
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -263,18 +263,18 @@ def required_validator(validator, required, instance, schema):
"type": "string",
"pattern": r"^([cbB\?hHiIlLqQfd]|\d*[spx])$",
}
struct_meta_schema["definitions"]["root"]["properties"][
"binaryFormat"
] = struct_meta_schema["properties"]["binaryFormat"]
struct_meta_schema["definitions"]["root"]["properties"]["binaryFormat"] = (
struct_meta_schema["properties"]["binaryFormat"]
)
# arrayLengthFormat matches regex and has default
struct_meta_schema["properties"]["arrayLengthFormat"] = {
"type": "string",
"pattern": r"^[BHILQ]$",
"default": "L",
}
struct_meta_schema["definitions"]["root"]["properties"][
"arrayLengthFormat"
] = struct_meta_schema["properties"]["arrayLengthFormat"]
struct_meta_schema["definitions"]["root"]["properties"]["arrayLengthFormat"] = (
struct_meta_schema["properties"]["arrayLengthFormat"]
)
# index is numeric
struct_meta_schema["properties"]["index"] = {"type": "number"}
struct_meta_schema["definitions"]["root"]["properties"]["index"] = struct_meta_schema[
Expand All @@ -285,14 +285,14 @@ def required_validator(validator, required, instance, schema):
"type": "string",
"default": "utf-8",
}
struct_meta_schema["definitions"]["root"]["properties"][
"stringEncoding"
] = struct_meta_schema["properties"]["stringEncoding"]
struct_meta_schema["definitions"]["root"]["properties"]["stringEncoding"] = (
struct_meta_schema["properties"]["stringEncoding"]
)
# nullTerminated is a boolean
struct_meta_schema["properties"]["nullTerminated"] = {"type": "boolean"}
struct_meta_schema["definitions"]["root"]["properties"][
"nullTerminated"
] = struct_meta_schema["properties"]["nullTerminated"]
struct_meta_schema["definitions"]["root"]["properties"]["nullTerminated"] = (
struct_meta_schema["properties"]["nullTerminated"]
)
# noLengthEncodingExhaustBuffer is a boolean
struct_meta_schema["properties"]["noLengthEncodingExhaustBuffer"] = {"type": "boolean"}
struct_meta_schema["definitions"]["root"]["properties"][
Expand Down
10 changes: 6 additions & 4 deletions python/tskit/text_formats.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2021-2022 Tskit Developers
# Copyright (c) 2021-2024 Tskit Developers
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -356,9 +356,11 @@ def dump_text(
).format(
site=mutation.site,
node=mutation.node,
time="unknown"
if util.is_unknown_time(mutation.time)
else mutation.time,
time=(
"unknown"
if util.is_unknown_time(mutation.time)
else mutation.time
),
derived_state=mutation.derived_state,
parent=mutation.parent,
metadata=metadata,
Expand Down
8 changes: 5 additions & 3 deletions python/tskit/trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -4283,9 +4283,11 @@ def __str__(self):
name.capitalize(),
table.num_rows,
util.naturalsize(table.nbytes),
"Yes"
if hasattr(table, "metadata") and len(table.metadata) > 0
else "No",
(
"Yes"
if hasattr(table, "metadata") and len(table.metadata) > 0
else "No"
),
]
]
)
Expand Down
12 changes: 7 additions & 5 deletions python/tskit/util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2018-2023 Tskit Developers
# Copyright (c) 2018-2024 Tskit Developers
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -457,10 +457,12 @@ def unicode_table(
def html_table(rows, *, header):
headers = "".join(f"<th>{h}</th>" for h in header)
rows = (
f'<td style="text-align: center;" colspan="{len(headers)}"><em>{row[11:]}'
f" rows skipped (tskit.set_print_options)</em></td>"
if "__skipped__" in row
else "".join(f"<td>{cell}</td>" for cell in row)
(
f'<td style="text-align: center;" colspan="{len(headers)}"><em>{row[11:]}'
f" rows skipped (tskit.set_print_options)</em></td>"
if "__skipped__" in row
else "".join(f"<td>{cell}</td>" for cell in row)
)
for row in rows
)
rows = "".join(f"<tr>{row}</tr>\n" for row in rows)
Expand Down

0 comments on commit d32d63f

Please sign in to comment.