Skip to content

Commit

Permalink
Code formatting: ruff format . && ruff --select=I --fix . (mchaput#55)
Browse files Browse the repository at this point in the history
# Description

`ruff format . && ruff --select=I --fix .`

Replaces both `black` and `isort` with `ruff` running rapidly in
`pre-commit`.

This separates automatic formatting changes (this PR) from more manual
and syntactical changes (in mchaput#54) to make the latter easier to review and
revert if necessary.

# Checklist:

- [x] I have performed a self-review of my code
- [ ] I have added comments to code where it is hard to understand
- [ ] I have made corresponding changes to the documentation
  • Loading branch information
ZeroCool940711 authored Feb 7, 2024
2 parents 53bf520 + 23a65f1 commit 6d4bd14
Show file tree
Hide file tree
Showing 209 changed files with 4,080 additions and 3,118 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/sweep-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ body:
Unit Tests: Write unit tests for <FILE>. Test each function in the file. Make sure to test edge cases.
Bugs: The bug might be in <FILE>. Here are the logs: ...
Features: the new endpoint should use the ... class from <FILE> because it contains ... logic.
Refactors: We are migrating this function to ... version because ...
Refactors: We are migrating this function to ... version because ...
2 changes: 1 addition & 1 deletion .github/workflows/deploy-github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ jobs:
# The GH actions bot is used by default if you didn't specify the two fields.
# You can swap them out with your own user credentials.
user_name: github-actions[bot]
user_email: 41898282+github-actions[bot]@users.noreply.github.com
user_email: 41898282+github-actions[bot]@users.noreply.github.com
2 changes: 1 addition & 1 deletion .github/workflows/first-interaction.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
If this is a bug report, please include relevant logs to help us debug the problem.
pr-message: |
Hello! Thank you for your contribution.
If you are fixing a bug, please reference the issue number in the description.
If you are implementing a feature request, please check with the maintainers that the feature will be accepted first.
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
types: [published]

workflow_dispatch: # This line allows manual triggering

#push:
# branches:
# - master
Expand Down
14 changes: 8 additions & 6 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.5.0
hooks:
- id: check-added-large-files
- id: check-ast
Expand All @@ -12,18 +12,20 @@ repos:
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: '24.1.1'

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.2.1
hooks:
- id: black
language_version: python3.11
exclude: ^notebooks
- id: ruff
args: [ --select=I ] # isort
- id: ruff-format

- repo: https://github.com/asottile/pyupgrade
rev: 'v3.15.0'
hooks:
- id: pyupgrade
args: [ --py38-plus ]

- repo: https://github.com/ikamensh/flynt/
rev: '1.0.1'
hooks:
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ sphinx:
python:
install:
# - requirements: requirements.txt
- requirements: docs/requirements.txt
- requirements: docs/requirements.txt
7 changes: 3 additions & 4 deletions benchmark/enron.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import division
import os.path, tarfile
import os.path
import tarfile
from email import message_from_string
from marshal import dump, load
from zlib import compress, decompress
Expand All @@ -10,11 +10,10 @@
pass

from whoosh import analysis, fields
from whoosh.compat import urlretrieve, next
from whoosh.compat import next, urlretrieve
from whoosh.support.bench import Bench, Spec
from whoosh.util import now


# Benchmark class


Expand Down
7 changes: 4 additions & 3 deletions benchmark/marc21.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from __future__ import with_statement, print_function
import fnmatch, logging, os.path, re
import fnmatch
import logging
import os.path
import re

from whoosh import analysis, fields, index, qparser, query, scoring
from whoosh.compat import range
from whoosh.util import now


log = logging.getLogger(__name__)


Expand Down
3 changes: 2 additions & 1 deletion benchmark/reuters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import gzip, os.path
import gzip
import os.path

from whoosh import analysis, fields, index, qparser, query
from whoosh.support.bench import Bench, Spec
Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,4 @@ xml:
pseudoxml:
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
2 changes: 1 addition & 1 deletion docs/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,4 @@ if "%1" == "pseudoxml" (
goto end
)

:end
:end
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
sphinx
sphinx_rtd_theme
sphinx-jsonschema
sphinx-jsonschema
3 changes: 0 additions & 3 deletions docs/source/analysis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,3 @@ change it. ;) Nothing requires that an Analyzer be implemented by calling a
tokenizer and filters. Tokenizers and filters are simply a convenient way to
structure the code. You're free to write an analyzer any way you want, as long
as it implements ``__call__``.



1 change: 0 additions & 1 deletion docs/source/api/analysis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,3 @@ Token classes and functions

.. autoclass:: Token
.. autofunction:: unstopped

2 changes: 0 additions & 2 deletions docs/source/api/codec/base.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,3 @@ Classes

.. autoclass:: Segment
:members:


5 changes: 0 additions & 5 deletions docs/source/api/collectors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,3 @@ Wrappers
.. autoclass:: TimeLimitCollector

.. autoclass:: TermsCollector





1 change: 0 additions & 1 deletion docs/source/api/columns.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,3 @@ Experimental columns
====================

.. autoclass:: ClampedNumericColumn

2 changes: 0 additions & 2 deletions docs/source/api/formats.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,3 @@ Formats
.. autoclass:: Characters
.. autoclass:: PositionBoosts
.. autoclass:: CharacterBoosts


1 change: 0 additions & 1 deletion docs/source/api/lang/wordnet.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ Low-level functions
.. autofunction:: parse_file
.. autofunction:: synonyms
.. autofunction:: make_index

7 changes: 0 additions & 7 deletions docs/source/api/qparser.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,3 @@ Operators
.. autoclass:: PrefixOperator
.. autoclass:: PostfixOperator
.. autoclass:: InfixOperator







1 change: 0 additions & 1 deletion docs/source/api/reading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ Exceptions
==========

.. autoexception:: TermNotFound

4 changes: 0 additions & 4 deletions docs/source/api/scoring.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,3 @@ Scoring utility classes
.. autoclass:: MultiWeighting

.. autoclass:: ReverseWeighting




1 change: 0 additions & 1 deletion docs/source/api/searching.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,3 @@ Exceptions

.. autoexception:: NoTermsException
.. autoexception:: TimeLimit

2 changes: 0 additions & 2 deletions docs/source/api/sorting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,3 @@ FacetType objects
.. autoclass:: UnorderedList
.. autoclass:: Count
.. autoclass:: Best


2 changes: 0 additions & 2 deletions docs/source/api/spelling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,3 @@ QueryCorrector objects
.. autoclass:: SimpleQueryCorrector

.. autoclass:: Correction


1 change: 0 additions & 1 deletion docs/source/api/support/charset.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@
Taken from http://speeple.com/unicode-maps.txt

.. autofunction:: charset_table_to_dict

1 change: 0 additions & 1 deletion docs/source/api/support/levenshtein.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@
.. autofunction:: relative

.. autofunction:: distance

1 change: 0 additions & 1 deletion docs/source/api/util.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@

.. automodule:: whoosh.util
:members:

2 changes: 0 additions & 2 deletions docs/source/api/writing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,3 @@ Exceptions
==========

.. autoexception:: IndexingError


6 changes: 0 additions & 6 deletions docs/source/batch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,3 @@ So, while ``multisegment=True`` is much faster than a normal writer, you should
only use it for large batch indexing jobs (or perhaps only for indexing from
scratch). It should not be the only method you use for indexing, because
otherwise the number of segments will tend to increase forever!






4 changes: 3 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import sys, os, os.path
import os
import os.path
import sys

sys.path.append(os.path.abspath("../../src"))
import whoosh
Expand Down
4 changes: 0 additions & 4 deletions docs/source/dates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,3 @@ Limitations

* ``DATETIME`` fields do not currently support open-ended ranges. You can
simulate an open ended range by using an endpoint far in the past or future.




2 changes: 0 additions & 2 deletions docs/source/facets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -767,5 +767,3 @@ Expert: writing your own facet
==============================

TBD.


6 changes: 0 additions & 6 deletions docs/source/fieldcaches.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,3 @@ Then you can pass an instance of your policy object to the ``set_caching_policy`
method::

searcher.set_caching_policy(MyPolicy())






1 change: 0 additions & 1 deletion docs/source/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,3 @@ Glossary
Term vector
A *forward index* for a certain field in a certain document. You can specify
in the Schema that a given field should store term vectors.

12 changes: 0 additions & 12 deletions docs/source/highlight.rst
Original file line number Diff line number Diff line change
Expand Up @@ -405,15 +405,3 @@ an analyzer::
``order``
An ordering function that determines the order of the "top" fragments in the
output text.












1 change: 0 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,3 @@ Indices and tables
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

1 change: 0 additions & 1 deletion docs/source/keywords.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,3 @@ Expansion models
The ``ExpansionModel`` subclasses in the :mod:` whoosh.classify` module implement
different weighting functions for key words. These models are translated into
Python from original Java implementations in Terrier.

1 change: 0 additions & 1 deletion docs/source/nested.rst
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,3 @@ additional searches for each found document.

Future versions of Whoosh may include "join" queries to make this process more
efficient (or at least more automatic).

3 changes: 0 additions & 3 deletions docs/source/ngrams.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,3 @@ whitespace and punctuation, while ``NGRAMWORDS`` extracts words from the text
using a tokenizer, then runs each word through the N-gram filter.

TBD.



7 changes: 1 addition & 6 deletions docs/source/parsing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ replace the default English tokens with your own regular expressions.

The :class:` whoosh.qparser.OperatorsPlugin` implements the ability to use AND,
OR, NOT, ANDNOT, and ANDMAYBE clauses in queries. You can instantiate a new
``OperatorsPlugin`` and use the ``And``, ``Or``, ``Not``, ``AndNot``, and
``OperatorsPlugin`` and use the ``And``, ``Or``, ``Not``, ``AndNot``, and
``AndMaybe`` keyword arguments to change the token patterns::

# Use Spanish equivalents instead of AND and OR
Expand Down Expand Up @@ -430,8 +430,3 @@ use the ``clean`` keyword argument::

Operators earlier in the list bind more closely than operators later in the
list.





1 change: 0 additions & 1 deletion docs/source/query.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ The classes in the :mod:` whoosh.query` module implement *queries* you can run a
TBD.

See :doc:`searching` for how to search the index using query objects.

3 changes: 0 additions & 3 deletions docs/source/querylang.rst
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,3 @@ in single quotes::
path:'MacHD:My Documents'
'term with spaces'
title:'function()'



1 change: 0 additions & 1 deletion docs/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,3 @@ Whoosh includes extra features for dealing with search results, such as
* Paginating the results (e.g. "Showing results 1-20, page 1 of 4").

See :doc:`searching` for more information.

1 change: 0 additions & 1 deletion docs/source/recipes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,3 @@ Is term X in document Y?
# ...or the slower but easier way
wordset = set(searcher.vector(500, "content").all_ids())
return "wobble" in wordset

1 change: 0 additions & 1 deletion docs/source/releases/1_0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -479,4 +479,3 @@ Misc
previous versions.

* Unit tests should no longer leave directories and files behind.

3 changes: 0 additions & 3 deletions docs/source/releases/2_0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,3 @@ Compatibility
now yield :class:` whoosh.reading.TermInfo` objects.

* The arguments to :class:` whoosh.query.FuzzyTerm` changed.



1 change: 0 additions & 1 deletion docs/source/releases/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ Release notes
2_0
1_0
0_3

4 changes: 0 additions & 4 deletions docs/source/schema.rst
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,3 @@ If you set ``FieldType.vector`` to a ``Format`` object, the indexing code will u
``Format`` object to store information about the terms in each document. Currently
by default Whoosh does not make use of term vectors at all, but they are
available to expert users who want to implement their own field types.




Loading

0 comments on commit 6d4bd14

Please sign in to comment.