Compare commits

...

2 Commits

Author SHA1 Message Date
Joshua Bronson cc284a7071 Upgrade dev dependencies.
Also:

* Remove pyright: ignore comments in favor of reducing associated
  diagnostic settings from "error" to "warning" in pyrightconfig.json.
  I.e. prefer seeing these (non-)issues as warnings in pyright output
  over smearing the code with more type checker gunk.

* Don't bother registering dict_keys as a BidictKeysView.

* Pin tox version in .github/workflows/test.yml, to prevent
  unpredictably picking up breaking changes that break CI (e.g.
  allowlist_externals from the recent 4.0 release).
2022-12-11 12:10:14 -05:00
Joshua Bronson 331bc83e8a Add .envrc 2022-12-11 11:09:09 -05:00
15 changed files with 44 additions and 53 deletions

1
.envrc Normal file
View File

@ -0,0 +1 @@
source .venv/bin/activate

View File

@ -39,7 +39,7 @@ jobs:
python-version: ${{ matrix.pyversion }}
cache: pip
cache-dependency-path: dev-deps/test.txt
- run: python -m pip install -U pip setuptools wheel tox
- run: python -m pip install -U pip setuptools wheel tox==4.0.5
- name: cache .hypothesis dir
uses: actions/cache@v3.0.11
with:

View File

@ -29,7 +29,7 @@ repos:
args: ["--uri-ignore-words-list", "*"] # https://github.com/codespell-project/codespell/issues/2473
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.278
rev: v1.1.283
hooks:
- id: pyright
@ -40,7 +40,7 @@ repos:
exclude: setup.py|docs/conf.py|tests
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.156
rev: v0.0.172
hooks:
- id: ruff

View File

@ -28,10 +28,6 @@ from ._iter import iteritems, inverted
from ._typing import KT, VT, MISSING, OKT, OVT, IterItems, MapOrIterItems
# Disable pyright strict diagnostics that are causing many false positives or are just not helpful in this file:
# pyright: reportPrivateUsage=false, reportUnknownArgumentType=false, reportUnknownMemberType=false, reportUnknownVariableType=false, reportUnnecessaryIsInstance=false
OldKV = t.Tuple[OKT[KT], OVT[VT]]
DedupResult = t.Optional[OldKV[KT, VT]]
Write = t.List[t.Callable[[], None]]
@ -47,10 +43,6 @@ class BidictKeysView(t.KeysView[KT], t.ValuesView[KT]):
"""
dict_keys: t.Type[t.KeysView[t.Any]] = type({}.keys())
BidictKeysView.register(dict_keys)
def get_arg(*args: MapOrIterItems[KT, VT]) -> MapOrIterItems[KT, VT]:
"""Ensure there's only a single arg in *args*, then return it."""
if len(args) > 1:
@ -495,7 +487,7 @@ class BidictBase(BidirectionalMapping[KT, VT]):
# If other is a bidict, use its existing backing inverse mapping, otherwise
# other could be a generator that's now exhausted, so invert self._fwdm on the fly.
inv = other.inverse if isinstance(other, BidictBase) else inverted(self._fwdm)
self._invm.update(inv) # pyright: ignore # https://github.com/jab/bidict/pull/242#discussion_r824223403
self._invm.update(inv)
#: Used for the copy protocol.
#: *See also* the :mod:`copy` module

View File

@ -36,7 +36,7 @@ class FrozenOrderedBidict(OrderedBidictBase[KT, VT]):
the ordering of the items can make the ordering dependence more explicit.
"""
__hash__: t.Callable[[t.Any], int] = frozenbidict.__hash__ # pyright: ignore
__hash__: t.Callable[[t.Any], int] = frozenbidict.__hash__
if t.TYPE_CHECKING:
@property

View File

@ -14,9 +14,6 @@ from ._bidict import bidict
from ._typing import KT, VT
# pyright: reportPrivateUsage=false, reportUnnecessaryIsInstance=false
class NamedBidictBase:
"""Base class that namedbidicts derive from."""
@ -96,4 +93,4 @@ def namedbidict(
NamedInv.__doc__ = f'NamedBidictInv({basename}) {typename!r}: {valname} -> {keyname}'
caller_module = _getframe(1).f_globals.get('__name__', '__main__')
NamedBidict.__module__ = NamedInv.__module__ = caller_module
return NamedBidict # pyright: ignore [reportUnknownVariableType]
return NamedBidict

View File

@ -23,9 +23,6 @@ from ._orderedbase import OrderedBidictBase
from ._typing import KT, VT
# pyright: reportPrivateUsage=false
class OrderedBidict(OrderedBidictBase[KT, VT], MutableBidict[KT, VT]):
"""Mutable bidict type that maintains items in insertion order."""
@ -60,7 +57,7 @@ class OrderedBidict(OrderedBidictBase[KT, VT], MutableBidict[KT, VT]):
korv = self._node_by_korv.inverse[node]
if self._bykey:
return korv, self._pop(korv)
return self.inverse._pop(korv), korv # pyright: ignore [reportGeneralTypeIssues]
return self.inverse._pop(korv), korv
def move_to_end(self, key: KT, last: bool = True) -> None:
"""Move the item with the given key to the end if *last* is true, else to the beginning.

View File

@ -6,35 +6,40 @@
#
build==0.9.0
# via pip-tools
cachetools==5.2.0
# via tox
chardet==5.1.0
# via tox
click==8.1.3
# via pip-tools
colorama==0.4.6
# via tox
distlib==0.3.6
# via virtualenv
filelock==3.8.0
filelock==3.8.2
# via
# tox
# virtualenv
packaging==21.3
packaging==22.0
# via
# build
# pyproject-api
# tox
pep517==0.13.0
# via build
pip-tools==6.11.0
# via bidict (pyproject.toml)
platformdirs==2.5.4
# via virtualenv
platformdirs==2.6.0
# via
# tox
# virtualenv
pluggy==1.0.0
# via tox
py==1.11.0
pyproject-api==1.2.1
# via tox
pyparsing==3.0.9
# via packaging
six==1.16.0
# via tox
tox==3.27.1
tox==4.0.5
# via bidict (pyproject.toml)
virtualenv==20.17.0
virtualenv==20.17.1
# via tox
wheel==0.38.4
# via pip-tools

View File

@ -10,13 +10,13 @@ babel==2.11.0
# via sphinx
beautifulsoup4==4.11.1
# via furo
certifi==2022.9.24
certifi==2022.12.7
# via requests
charset-normalizer==2.1.1
# via requests
docutils==0.19
# via sphinx
furo==2022.9.29
furo==2022.12.7
# via bidict (pyproject.toml)
idna==3.4
# via requests
@ -26,14 +26,12 @@ jinja2==3.1.2
# via sphinx
markupsafe==2.1.1
# via jinja2
packaging==21.3
packaging==22.0
# via sphinx
pygments==2.13.0
# via
# furo
# sphinx
pyparsing==3.0.9
# via packaging
pytz==2022.6
# via babel
requests==2.28.1

View File

@ -8,13 +8,13 @@ cfgv==3.3.1
# via pre-commit
distlib==0.3.6
# via virtualenv
filelock==3.8.0
filelock==3.8.2
# via virtualenv
identify==2.5.9
# via pre-commit
nodeenv==1.7.0
# via pre-commit
platformdirs==2.5.4
platformdirs==2.6.0
# via virtualenv
pre-commit==2.20.0
# via bidict (pyproject.toml)
@ -22,7 +22,7 @@ pyyaml==6.0
# via pre-commit
toml==0.10.2
# via pre-commit
virtualenv==20.17.0
virtualenv==20.17.1
# via pre-commit
# The following packages are considered to be unsafe in a requirements file:

View File

@ -12,7 +12,7 @@ attrs==22.1.0
# pytest
babel==2.11.0
# via sphinx
certifi==2022.9.24
certifi==2022.12.7
# via requests
charset-normalizer==2.1.1
# via requests
@ -36,7 +36,7 @@ jinja2==3.1.2
# via sphinx
markupsafe==2.1.1
# via jinja2
packaging==21.3
packaging==22.0
# via
# pytest
# sphinx
@ -54,8 +54,6 @@ pygaljs==1.0.2
# via pytest-benchmark
pygments==2.13.0
# via sphinx
pyparsing==3.0.9
# via packaging
pytest==7.2.0
# via
# bidict (pyproject.toml)

View File

@ -1 +0,0 @@
aside.footnote > span { float:left; padding-right: 0.25rem; } // https://github.com/pradyunsg/furo/discussions/489#discussioncomment-3345304

View File

@ -165,7 +165,7 @@ html_static_path = ['_static']
#html_extra_path = []
# https://docs.readthedocs.io/en/stable/guides/adding-custom-css.html#adding-custom-css-or-javascript-to-sphinx-documentation
html_css_files = ['custom.css']
# html_css_files = ['custom.css']
html_js_files = ['custom.js']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,

View File

@ -1,14 +1,17 @@
// vim: set ft=json5:
{
"include": [
"bidict",
],
"exclude": [
"docs",
"tests",
"run_tests.py",
"tests",
],
"strict": [
"bidict",
],
"typeCheckingMode": "strict",
// https://github.com/microsoft/pyright/blob/main/docs/configuration.md#diagnostic-rule-defaults
"reportGeneralTypeIssues": "warning",
"reportPrivateUsage": "warning",
"reportUnknownArgumentType": "warning",
"reportUnknownMemberType": "warning",
"reportUnknownVariableType": "warning",
"reportUnnecessaryIsInstance": "warning",
"reportUnnecessaryTypeIgnoreComment": "warning",
}

View File

@ -10,6 +10,7 @@ isolated_build = true
[testenv]
deps = -r dev-deps/test.txt
allowlist_externals = ./run_tests.py
commands = ./run_tests.py
[testenv:lint]