Skip to content
This repository was archived by the owner on Feb 10, 2026. It is now read-only.

Commit 92a3b71

Browse files
author
Reece Hart
committed
added new ignores for previously unchanged files
1 parent 83ea251 commit 92a3b71

28 files changed

+72
-123
lines changed

docs/conf.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# eutils documentation build configuration file, created by
43
# sphinx-quickstart on Tue Aug 11 10:03:31 2015.
@@ -12,12 +11,10 @@
1211
# All configuration values have a default; values that are commented out
1312
# serve to show the default.
1413

15-
import sys
16-
import os
1714

1815
import sphinx_rtd_theme
1916

20-
import biocommons.eutils as eutils
17+
from biocommons import eutils
2118

2219
# If extensions (or modules to document with autodoc) are in another directory,
2320
# add these directories to sys.path here. If the directory is relative to the
@@ -55,7 +52,7 @@
5552

5653
# General information about the project.
5754
project = "eutils"
58-
copyright = "2018, eutils Committers"
55+
copyright = "2018, eutils Committers" # noqa: A001
5956

6057
# The version info for the project you're documenting, acts as replacement for
6158
# |version| and |release|, also used in various other places throughout the

pyproject.toml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ testpaths = ["src", "tests"]
130130
[tool.ruff]
131131
line-length = 100
132132
src = ["src", "tests"]
133-
target-version = "py314"
133+
target-version = "py313"
134134

135135
[tool.ruff.format]
136136
docstring-code-format = true
@@ -198,22 +198,37 @@ select = [
198198
# These warnings became visible with the adoption of ruff. They
199199
# should be addressed in separate issues.
200200
"src/**/*.py" = [
201+
# "C416", # Unnecessary list comprehension (rewrite using `list()`)
202+
"A001", # Variable `id` is shadowing a Python builtin
203+
"A002", # Function argument `id` is shadowing a Python builtin
204+
"B006", # Do not use mutable data structures for argument defaults
201205
"C416", # Unnecessary list comprehension (rewrite using `list()`)
202206
"E741", # Ambiguous variable name: `l`
203207
"EM101", # Exception must not use a string literal, assign to variable first
208+
"EM102", # Exception must not use an f-string literal, assign to variable first
204209
"F522", # `.format` call has unused named argument(s): n
205210
"F524", # `.format` call is missing argument(s) for placeholder(s): n=n
206211
"F821", # Undefined name `pas`
212+
"G003", # Logging statement uses `+`
213+
"G004", # Logging statement uses f-string
207214
"PTH118", # `os.path.join()` should be replaced by `Path` with `/` operator
208215
"PTH120", # `os.path.dirname()` should be replaced by `Path.parent`
209216
"RET504", # Unnecessary assignment to `nodes` before `return` statement
210217
"S101", # Use of `assert` detected
218+
"S108", # Probable insecure usage of temporary file or directory: "/tmp/SQLiteCache-test.db"
219+
"S301", # `pickle` and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue
220+
"SIM101", # Multiple `isinstance` calls for `xml`, merge into a single call
211221
"TRY003", # Avoid specifying long messages outside the exception class
212222
"UP008", # Use `super()` instead of `super(__class__, self)`
213223
]
214224
"tests/**/*.py" = [
215225
"C405", # Unnecessary list literal (rewrite as a set literal)
226+
"N801", # Class name (various) should use CapWords convention
227+
"N802", # Function name (various) should be lowercase
228+
"PLR2004", # Magic value used in comparison
229+
"PTH107", # `os.remove()` should be replaced by `Path.unlink()`
216230
"S101", # Use of `assert` detected
231+
"UP008", # Use `super()` instead of `super(__class__, self)`
217232
]
218233

219234
[tool.setuptools]

src/biocommons/eutils/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from importlib.metadata import PackageNotFoundError, version
32

43
from ._internal.client import Client

src/biocommons/eutils/_internal/client.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# -*- coding: utf-8 -*-
2-
31
import logging
4-
import os
52

63
import lxml.etree as le
74

@@ -15,11 +12,10 @@
1512
from .xmlfacades.pubmedarticleset import PubmedArticleSet
1613
from .xmlfacades.pubmedcentralarticleset import PubmedCentralArticleSet
1714

18-
1915
logger = logging.getLogger(__name__)
2016

2117

22-
class Client(object):
18+
class Client:
2319
"""class-based access to NCBI E-Utilities, returning Python classes
2420
with rich data accessors
2521
@@ -69,8 +65,8 @@ def esearch(self, db, term):
6965
esr = ESearchResult(self._qs.esearch({"db": db, "term": term}))
7066
if esr.count > esr.retmax:
7167
logger.warning(
72-
"NCBI found {esr.count} results, but we truncated the reply at {esr.retmax}"
73-
" results; see https://github.com/biocommons/eutils/issues/124/".format(esr=esr)
68+
f"NCBI found {esr.count} results, but we truncated the reply at {esr.retmax}"
69+
" results; see https://github.com/biocommons/eutils/issues/124/"
7470
)
7571
return esr
7672

@@ -90,7 +86,7 @@ def efetch(self, db, id):
9086
return ExchangeSet(xml)
9187
if db in ["pmc"]:
9288
return PubmedCentralArticleSet(doc)
93-
raise EutilsError("database {db} is not currently supported by eutils".format(db=db))
89+
raise EutilsError(f"database {db} is not currently supported by eutils")
9490

9591

9692
# <LICENSE>

src/biocommons/eutils/_internal/exceptions.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,30 @@
1-
# -*- coding: utf-8 -*-
2-
3-
41
class EutilsError(Exception):
52
"""Base class for all Eutils exceptions, and also used to raise
63
general exception.
74
85
"""
96

10-
pass
11-
127

138
class EutilsNCBIError(EutilsError):
149
"""Raised when NCBI returns data that appears to be incorrect or
1510
invalid.
1611
1712
"""
1813

19-
pass
20-
2114

2215
class EutilsNotFoundError(EutilsError):
2316
"""Raised when the requested data is not available. (Used only by the
2417
:mod:`eutils.sketchy.clientx` interface currently.)
2518
2619
"""
2720

28-
pass
29-
3021

3122
class EutilsRequestError(EutilsError):
3223
"""Raised when NCBI responds with an error, such as when a non-existent
3324
database is specified.
3425
3526
"""
3627

37-
pass
38-
3928

4029
# <LICENSE>
4130
# Copyright 2015 eutils Committers

src/biocommons/eutils/_internal/sqlitecache.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
# -*- coding: utf-8 -*-
2-
31
"""simple key-value cache with transparent payload compression and expiration
42
53
Taken from http://bitbucket.org/reece/rcore/
64
"""
75

86
import logging
9-
import os
107
import pickle
118
import sqlite3
129
import zlib
@@ -29,7 +26,7 @@ def val_from(pobj, compress):
2926
return pickle.loads(zlib.decompress(pobj) if compress else pobj)
3027

3128

32-
class SQLiteCache(object):
29+
class SQLiteCache:
3330
############################################################################
3431
## Exposed methods
3532
def __init__(self, db_path, compress_values=True):
@@ -46,16 +43,14 @@ def expire(self, age):
4643
## Special Python methods
4744

4845
def __str__(self):
49-
return "SQLiteCache(db_path={self._db_path},compress_values={self.compress_values})".format(
50-
self=self
51-
)
46+
return f"SQLiteCache(db_path={self._db_path},compress_values={self.compress_values})"
5247

5348
def __dir__(self):
5449
self._logger.debug("__dir__()")
5550
return [key_from(row[0]) for row in self._execute("SELECT key FROM cache", [])]
5651

5752
def __getitem__(self, key):
58-
self._logger.debug("__getitem__({key})".format(key=key))
53+
self._logger.debug(f"__getitem__({key})")
5954
cur = self._execute("SELECT value,value_compressed FROM cache WHERE key = ?", [key_to(key)])
6055
row = cur.fetchone()
6156
if row is None:
@@ -64,20 +59,20 @@ def __getitem__(self, key):
6459

6560
def __setitem__(self, key, value):
6661
db_val = val_to(value, self.compress_values)
67-
self._logger.debug("__setitem__({key},({vlen} bytes))".format(key=key, vlen=len(db_val)))
62+
self._logger.debug(f"__setitem__({key},({len(db_val)} bytes))")
6863
self._execute(
6964
"INSERT OR REPLACE INTO cache (key,value_compressed,value) VALUES (?,?,?)",
7065
[key_to(key), self.compress_values, db_val],
7166
)
7267

7368
def __delitem__(self, key):
74-
self._logger.debug("__delitem__({key})".format(key=key))
69+
self._logger.debug(f"__delitem__({key})")
7570
cur = self._execute("DELETE FROM cache WHERE key = ?", [key_to(key)])
7671
if cur.rowcount == 0:
7772
raise KeyError(key)
7873

7974
def __contains__(self, key):
80-
self._logger.debug("__contains__({key})".format(key=key))
75+
self._logger.debug(f"__contains__({key})")
8176
return self._fetch1v(
8277
"SELECT EXISTS(SELECT 1 FROM cache WHERE key=? LIMIT 1)", [key_to(key)]
8378
)
@@ -110,11 +105,7 @@ def _get_schema_version(self):
110105

111106
def _execute(self, query, params=[]):
112107
cur = self._con.cursor()
113-
self._logger.debug(
114-
"executing query <{query}> with params <{nvars} vars>".format(
115-
query=query, nvars=len(params)
116-
)
117-
)
108+
self._logger.debug(f"executing query <{query}> with params <{len(params)} vars>")
118109
cur.execute(query, params)
119110
return cur
120111

src/biocommons/eutils/_internal/utils.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
3-
41
def xml_get1(node, xpath):
52
return node.xpath(xpath)[0]
63

src/biocommons/eutils/_internal/xmlfacades/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
"""xmlfacades/__init__.py doc string"""
42

53
# <LICENSE>

src/biocommons/eutils/_internal/xmlfacades/base.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
import logging
42

53
import lxml.etree
@@ -9,7 +7,7 @@
97
logger = logging.getLogger(__name__)
108

119

12-
class Base(object):
10+
class Base:
1311
"""Root class for all xmlfacade classes.
1412
1513
This class is instantiated only by subclasses.
@@ -33,12 +31,10 @@ def __init__(self, xml):
3331
raise EutilsError("Cannot create object from type " + type(xml).__name__)
3432

3533
if self._root_tag is None:
36-
raise EutilsError("_root_tag not defined for class {}".format(type(self).__name__))
37-
elif self._root_tag != self._xml_root.tag:
34+
raise EutilsError(f"_root_tag not defined for class {type(self).__name__}")
35+
if self._root_tag != self._xml_root.tag:
3836
raise EutilsError(
39-
"XML for {} object must be a {} element (got {})".format(
40-
type(self).__name__, self._root_tag, self._xml_root.tag
41-
)
37+
f"XML for {type(self).__name__} object must be a {self._root_tag} element (got {self._xml_root.tag})"
4238
)
4339

4440

src/biocommons/eutils/_internal/xmlfacades/dbinfo.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
"""Provides support for parsing NCBI einfo queries as described here:
42
53
http://www.ncbi.nlm.nih.gov/books/NBK25499/#chapter4.EInfo

0 commit comments

Comments
 (0)