From 674d7e14a0d524cc286b16629d56e72836fb7030 Mon Sep 17 00:00:00 2001 From: manonBlanco <blanco@teklia.com> Date: Fri, 24 Nov 2023 12:32:19 +0100 Subject: [PATCH] Comply with ruff's PTH rule --- nerval/evaluate.py | 11 +++++------ pyproject.toml | 2 ++ setup.py | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/nerval/evaluate.py b/nerval/evaluate.py index e72fd08..7feec7b 100644 --- a/nerval/evaluate.py +++ b/nerval/evaluate.py @@ -1,5 +1,4 @@ import logging -import os from csv import reader from pathlib import Path from typing import List @@ -343,14 +342,14 @@ def run(annotation: Path, prediction: Path, threshold: int, verbose: bool) -> di return scores -def run_multiple(file_csv, folder, threshold, verbose): +def run_multiple(file_csv: Path, folder: Path, threshold: int, verbose: bool): """Run the program for multiple files (correlation indicated in the csv file)""" # Read the csv in a list - with open(file_csv) as read_obj: + with file_csv.open() as read_obj: csv_reader = reader(read_obj) list_cor = list(csv_reader) - if os.path.isdir(folder): + if folder.is_dir(): list_bio_file = list(folder.rglob("*.bio")) count = 0 @@ -362,10 +361,10 @@ def run_multiple(file_csv, folder, threshold, verbose): predict = None for file in list_bio_file: - if row[0] == os.path.basename(file): + if row[0] == file.name: annot = file for file in list_bio_file: - if row[1] == os.path.basename(file): + if row[1] == file.name: predict = file if annot and predict: diff --git a/pyproject.toml b/pyproject.toml index 447804e..28ef1df 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,4 +33,6 @@ select = [ "Q", # flake8-unused-arguments "ARG", + # flake8-use-pathlib + "PTH", ] diff --git a/setup.py b/setup.py index c15ce58..611c366 100644 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ def parse_requirements(): setup( name="nerval", - version=open("VERSION").read(), + version=Path("VERSION").read_text(), description="Tool to evaluate NER on noisy text.", author="Teklia", author_email="contact@teklia.com", -- GitLab