From d2d8ce286a36bd0933a01d2f1e063fea44ca36ec Mon Sep 17 00:00:00 2001 From: Diego Argueta Date: Sat, 20 Nov 2021 09:50:12 -0800 Subject: [PATCH] 0.10.5 (#36) --- .bumpversion.cfg | 2 +- binobj/__init__.py | 2 +- binobj/fields/base.py | 11 ++++++++++- docs/source/CHANGELOG.rst | 27 +++++++++++++++++++++++++++ docs/source/conf.py | 4 ++-- lint-requirements.txt | 20 ++++++++++++-------- setup.cfg | 7 ++++--- test-requirements.txt | 8 +++++--- tox.ini | 21 ++++++++++++++++----- 9 files changed, 78 insertions(+), 24 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 82a6e111..4b7c7eba 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.10.4 +current_version = 0.10.5 commit = True tag = False tag_name = {new_version} diff --git a/binobj/__init__.py b/binobj/__init__.py index 68372b5e..8fb6e126 100644 --- a/binobj/__init__.py +++ b/binobj/__init__.py @@ -14,5 +14,5 @@ def __to_version_info(): # Do not modify directly; use ``bumpversion`` command instead. -__version__ = "0.10.4" +__version__ = "0.10.5" __version_info__ = __to_version_info() diff --git a/binobj/fields/base.py b/binobj/fields/base.py index 0317497d..94b482a0 100644 --- a/binobj/fields/base.py +++ b/binobj/fields/base.py @@ -349,17 +349,26 @@ def compute_value_for_dump( # FIXME (dargueta): Don't pass None for the context variable. if not self.present(all_values, None, None): return NOT_PRESENT + if self.name in all_values: + # The value is already set in the struct so we don't need to do anything. return typing.cast(Optional[T], all_values[self.name]) + + # The value is *not* set in the struct. Either this field must have a default + # value, or it must be a computed field. if self._default is not UNDEFINED: # Theoretically if self._default is a callable that returns UNDEFINED we # could run into trouble here. Get the return value. to_return = self.default if to_return is not UNDEFINED: return to_return + + # If we get here then _default is UNDEFINED or the callable it's set to returned + # UNDEFINED. if self._compute_fn is not None: return self._compute_fn(self, all_values) + # No default value and this isn't a computed field either. raise errors.MissingRequiredValueError(field=self) def computes(self, method: Callable[["Field[T]", StrDict], Optional[T]]) -> None: @@ -471,7 +480,7 @@ def _size_for_value(self, value: Optional[T]) -> Optional[int]: return typing.cast(int, self._size) return None - def _get_expected_size(self, field_values: StrDict) -> int: + def _get_expected_size(self, field_values: StrDict) -> int: # pragma: no cover """Compatibility shim -- this function was made public in 0.9.0.""" warnings.warn( "_get_expected_size was made public in 0.9.0. The private form has been" diff --git a/docs/source/CHANGELOG.rst b/docs/source/CHANGELOG.rst index 431ee805..f8638499 100644 --- a/docs/source/CHANGELOG.rst +++ b/docs/source/CHANGELOG.rst @@ -1,6 +1,33 @@ Changelog ========= +0.10.5 +------ + +Released 2021-11-20 + +Bugfixes +~~~~~~~~ + +Installation breaks on Python 3.5 due to `this bug`_ in more-itertools. I've +put a new upper bound on that dependency (only on 3.5) to fix this. + +Other Changes +~~~~~~~~~~~~~ + +Loosened upper bound on the ``typing-inspect`` dependency to allow the latest +versions. + +Internal Changes +~~~~~~~~~~~~~~~~ + +* Bumped test dependencies. +* Fixed Tox envs for linting and type checking, which were silently broken. +* Added some more code comments. + + +.. _this bug: https://github.com/more-itertools/more-itertools/issues/578 + 0.10.4 ------ diff --git a/docs/source/conf.py b/docs/source/conf.py index 4630d41d..8b47195c 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -66,9 +66,9 @@ # built documents. # # The short X.Y version. -version = "0.10.4" +version = "0.10.5" # The full version, including alpha/beta/rc tags. -release = "0.10.4" +release = "0.10.5" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/lint-requirements.txt b/lint-requirements.txt index 791f620e..426c1c2a 100644 --- a/lint-requirements.txt +++ b/lint-requirements.txt @@ -1,19 +1,23 @@ # For reproducibility please pin all direct dependencies as tightly as possible, # down to the patch version. -black==21.8b0 -flake8==3.9.2 +black==21.11b1 +flake8==4.0.1 flake8-black==0.2.3 flake8-blind-except==0.2.0 -flake8-bugbear==21.4.3 -flake8-comprehensions==3.6.1 +flake8-bugbear==21.9.2 +flake8-builtins==1.5.3 +flake8-comprehensions==3.7.0 flake8-debugger==4.0.0 +flake8-deprecated==1.3 flake8-docstrings==1.6.0 flake8-implicit-str-concat==0.2.0 -flake8-isort==4.0.0 +flake8-isort==4.1.1 +flake8-loopy==1.1.0 flake8-logging-format==0.6.0 +# flake8-unused-arguments==0.0.9 # Uncomment this later -# flake8-simplify==0.14.0 -isort==5.9.3 +# flake8-simplify==0.14.2 +isort==5.10.1 mccabe==0.6.1 mypy==0.910 @@ -21,5 +25,5 @@ mypy==0.910 # Indirect dependencies go below this line. Avoid pinning them any tighter than # necessary. You should only add dependencies here that require pinning to ensure # certain features or bugfixes are present. -pydocstyle>=5.1.0 +pydocstyle>=6 types-setuptools diff --git a/setup.cfg b/setup.cfg index 8b2fdbaf..5de2d926 100644 --- a/setup.cfg +++ b/setup.cfg @@ -26,13 +26,14 @@ project_urls: Source=https://www.github.com/dargueta/binobj Tracker=https://www.github.com/dargueta/binobj/issues ; Do not modify the version manually -- use the bumpversion CLI tool -version: 0.10.4 +version: 0.10.5 [options] install_requires: attrs>=18.2.0 - more-itertools>=4.0, <9 - typing-inspect>=0.4.0, <0.7 ; python_version<="3.7" + more-itertools>=4.0, <8.11 ; python_version<"3.6" + more-itertools>=4.0, <9 ; python_version>="3.6" + typing-inspect>=0.4.0, <0.8 ; python_version<="3.7" python_requires: >=3.5 [options.package_data] diff --git a/test-requirements.txt b/test-requirements.txt index d7b4220a..2509b98c 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,7 +1,8 @@ pytest==6.2.5 ; python_version>="3.6" pytest==6.1.2 ; python_version<"3.6" -pytest-cov==2.12.1 -pytest-randomly==3.10.1 ; python_version>="3.6" +pytest-cov==3.0.0 ; python_version>="3.6" +pytest-cov==2.12.1 ; python_version<"3.6" +pytest-randomly==3.10.2 ; python_version>="3.6" pytest-randomly==3.5.0 ; python_version<"3.6" coverage-pyver-pragma==0.3.0 ; python_version>="3.6" @@ -9,4 +10,5 @@ coverage-pyver-pragma==0.3.0 ; python_version>="3.6" # Indirect dependencies go below this line. Avoid pinning them any tighter than necessary. # You should only add dependencies here that require pinning to ensure certain features or # bugfixes are present. -coverage>=5.5 +coverage>=5.5 ; python_version <"3.6" +coverage>=6 ; python_version>="3.6" diff --git a/tox.ini b/tox.ini index b121befe..119ba989 100644 --- a/tox.ini +++ b/tox.ini @@ -12,12 +12,15 @@ passenv = COV_PLATFORM COV_PYTHON_IMPLEMENTATION -[testenv:lint,mypy] +[testenv:lint] basepython = python3.8 deps = -rlint-requirements.txt -commands = - lint: flake8 --max-complexity 9 - mypy: mypy --show-error-codes binobj +commands = flake8 --max-complexity 9 + +[testenv:mypy] +basepython = python3.8 +deps = -rlint-requirements.txt +commands = mypy --show-error-codes binobj [pytest] addopts = @@ -74,15 +77,23 @@ multi_line_output = 3 include_trailing_comma = true [mypy] -strict_optional = true +allow_untyped_globals = false +allow_redefinition = false +check_untyped_defs = true disallow_any_decorated = true disallow_any_generics = true disallow_any_unimported = true disallow_incomplete_defs = true disallow_subclassing_any = true disallow_untyped_calls = true +disallow_untyped_decorators = true disallow_untyped_defs = true ignore_missing_imports = false +implicit_reexport = false +no_implicit_optional = true +show_error_codes = true +strict_optional = true +warn_no_return = true warn_unreachable = true warn_unused_ignores = true warn_redundant_casts = true