Skip to content

Commit

Permalink
tox: Adding py311, isort, ruff.
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienPalard committed Mar 10, 2023
1 parent d898074 commit db9e12a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
33 changes: 14 additions & 19 deletions oeis.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
"""Implementation of a few integer sequences from the OEIS."""
import argparse
import math
from itertools import count
from functools import lru_cache, reduce
from random import random, choice
from decimal import Decimal, localcontext
from typing import (
Callable,
Dict,
Iterable,
Iterator,
List,
Sequence,
Union,
overload,
)
import sys
from decimal import Decimal, localcontext
from functools import lru_cache, reduce
from itertools import count
from random import choice, random
from typing import Callable, Dict, Iterable, Iterator, List, Sequence, Union, overload

# Version format is YYYY.MM.DD (https://calver.org/)
__version__ = "2021.1.3"
Expand Down Expand Up @@ -144,7 +135,7 @@ def __getitem__(self, key: int) -> int:
def __getitem__(self, key: slice) -> Sequence[int]:
"""Return a slice from an integer sequence."""

def __getitem__(self, key: Union[int, slice]) -> Union[int, Sequence[int]]: # type: ignore
def __getitem__(self, key: Union[int, slice]) -> Union[int, Sequence[int]]:
"""Return a value from the sequence (or a slice of it)."""
if isinstance(key, slice):
key = self.check_slice(key)
Expand Down Expand Up @@ -185,7 +176,7 @@ def __getitem__(self, key: int) -> int:
def __getitem__(self, key: slice) -> Sequence[int]:
"""Return a slice from an integer sequence."""

def __getitem__(self, key: Union[int, slice]) -> Union[int, Sequence[int]]: # type: ignore
def __getitem__(self, key: Union[int, slice]) -> Union[int, Sequence[int]]:
"""Return a value from the sequence (or a slice of it)."""
if isinstance(key, slice):
self.check_slice(key)
Expand Down Expand Up @@ -263,7 +254,8 @@ def wrapper(function: SerieGenerator) -> IntegerSequenceFromGenerator:
def A000037(n: int) -> int:
"""Give Numbers that are not squares (or, the nonsquares).
a(n) = A000194(n) + n = floor(1/2 *(1 + sqrt(4*n-3))) + n. - Jaroslav Krizek, Jun 14 2009
a(n) = A000194(n) + n = floor(1/2 *(1 + sqrt(4*n-3))) + n.
- Jaroslav Krizek, Jun 14 2009
"""
from math import floor, sqrt

Expand Down Expand Up @@ -349,7 +341,7 @@ def A000032() -> Iterable[int]:

@oeis.from_function()
def A000119(n: int) -> int:
"""Give the number of representations of n as a sum of distinct Fibonacci numbers."""
"""Give the number of representations of n as a sum of distinct Fib. numbers."""

def f(x, y, z):
if x < y:
Expand Down Expand Up @@ -679,7 +671,10 @@ def A001969() -> Iterable[int]:

@oeis.from_function(offset=1)
def A064367(n: int) -> int:
"""Show result of a(n) = 2^n mod prime(n), or 2^n = k*prime(n) + a(n) with integer k."""
"""Show result of a(n) = 2^n mod prime(n).
Or 2^n = k*prime(n) + a(n) with integer k.
"""
from sympy.ntheory import prime

return 2**n % prime(n)
Expand Down
12 changes: 11 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exclude_lines =
if __name__ == .__main__.:

[tox]
envlist = py3{7,8,9,10}-{low,high}, flake8, mypy, black, pylint, pydocstyle, coverage
envlist = py3{7,8,9,10,11}-{low,high}, flake8, mypy, black, pylint, pydocstyle, coverage, isort, ruff
isolated_build = True
skip_missing_interpreters = True

Expand Down Expand Up @@ -77,3 +77,13 @@ commands = pylint --disable import-outside-toplevel,invalid-name oeis.py
deps = pydocstyle
skip_install = True
commands = pydocstyle oeis.py

[testenv:isort]
deps = isort
skip_install = True
commands = isort --profile=black oeis.py

[testenv:ruff]
deps = ruff
skip_install = True
commands = ruff check oeis.py

0 comments on commit db9e12a

Please sign in to comment.