Djblets 3.3: Typing, Symbols, AmountSelectorWidget

Djblets 3.3 introduces a new form field widget for unit-based number input and further enhances our support for Python type hints.

Typing Improvements

The following modules now support Python type hints:

A new djblets.util.typing module has been added with new useful types, including KwargsDict, StrOrPromise, JSONValue, JSONDict, and JSONList.

Utility Symbols

A new djblets.util.symbols module has been added with utility symbols that can be used in APIs.

Right now, this includes UNSET, which can be used as a default result or value in many APIs instead of using None. More will be added in time.

AmountSelectorWidget

The new AmountSelectorWidget can be used in form fields to let users input a number and select a unit (such as bytes, kilobytes, or megabytes).

See the release notes for more details on Djblets 3.3.

Installation

$ pip3 install Djblets==3.3

Learn More

Djblets 3.3 release notes
Documentation
PyPI

Read More

beanbag-docutils 2.2: Enhanced JSON Output

beanbag-docutils is our collection of extensions for the Sphinx documentation platform.

This is a major feature release that introduces some new capabilities for JSON output, making it easier to integrate documentation into your own sites:

  • The metadata extension extracts .. meta:: into the JSON output for a page.
  • The json_writer extension replaces the sphinxcontrib-serializinghtml JSON writer and includes both a copy of the docs-wide Table of Contents structure in the globalcontext.fjson file and per-page anchor navigation HTML in the page’s .fjson file.

You can see how we make use of these new capabilities in the brand-new Review Board documentation site.

Installation

$ pip3 install beanbag-docutils==2.2

Learn More

Read More

ChangeLog: Office Document Review, New Draft Banner, Actions Rewrite

Welcome back to ChangeLog, where we dive into the latest developments around Review Board, Power Pack, and other Beanbag products.

Today we’re going to cover a major feature coming to Power Pack, plus some work that’s in progress for Review Board 6.

Office Document Review in Power Pack

Power Pack has long offered support for reviewing and diffing PDF documents. This has been used by companies to review documentation, contracts, schematics, industrial designs, and more.

Soon, you’ll be able to review a few more file types:

  • Microsoft Office documents (Word, Excel, PowerPoint)
  • OpenOffice/LibreOffice documents (Writer, Calc, Impress)
A sample review session for a LibreOffice Impress document, covering a presentation titled "Writing Enterprise WebApps in Bourne Shell." There's a comment saying "This seems like a really bad idea." The second page says "Bourne Shell: Why Not?" and states "It's on every system; It's memory-safe; You might not completely nuke your system unexpectedly, maybe."

It also supports diffing! You’ll be able to view the differences in new revisions of Word documents, spreadsheets, and presentations.

A screenshot showing a side-by-side diff of two PowerPoint presentations. The old text, "You definitely won't completely nuke your system unexpectedly" is shown on the left in red. On the right, the replacement text is shown in green: "You might not completely nuke your system unexpectedly." The red and green show only the changed words.

This will require setting up a small microservice, which we’ll provide via Docker.

When uploading a supported document to Review Board, Power Pack will send it along to the microservice to convert to PDF for render. This supports not just showing the document, but diffing multiple revisions of the document as well.

Both the original document and the PDF can also be downloaded to the local machine.

We’re expecting this will be released in Power Pack 6 by early/mid-2023.

The Unified Draft Banner

Over the years, we’ve come up with all sorts of ideas for improving the review experience in Review Board, and in Review Board 6, we’re kicking some of our plans into action, starting with the Unified Draft Banner.

This replaces the current, basic draft banners shown on review requests and reviews with a new one that:

  • Helps you see what all you have pending to publish (review requests, reviews, replies).
  • Let’s you publish them either all at once (with one combined e-mail) or individually, as before.
  • Shows additional information on what you’re reviewing, like the list of files in the diff viewer.
  • Can be further augmented by extensions.

When creating a new review request, the banner will look pretty similar to today:

Basic draft banner shown when posting a brand-new review request. This states the review request is a draft, and includes a combo Publish/Options button, followed by a Discard button.

When you have multiple things in flight (such as review request updates and replies to reviews), you can publish them in one go:

A draft banner showing that there are both changes to the review request pending, and one reply to a review. This lists "Changes an 1 reply" as a drop-down menu for selecting just a subset; a "Publish All"/Options combo button, and a "Review" drop-down menu. On the next line is a "Describe your changes" field for describing the new review request draft.

Or you can switch to a specific draft to publish:

The drop-down for the "Changes and 1 reply" menu, showing each draft. These can be clicked. The items are: 1) "Review request changes", and 2) "Replying to David Trowbridge's review"

The gear menu controls options for your publishes (depending on what’s being published):

The drop-down options on the "Publish All" combo button. This shows a single "Archive after publishing" checkbox.

The “Review” menu will always be present, and can be used to guide users to creating a new review, adding general comments, and quickly posting a Ship It! review.

This is still in the early stages. We’ll provide some more screenshots as development progresses.

Actions Rewrite

Behind-the-scenes, we have the “actions” system, which lets Review Board and extensions register buttons in some parts of the review request UI. It’s where the “Ship It!”, “Close”, “Upload Diff”, etc. buttons all come from.

The current list of review request actions. This shows: "Star", "Archive", "Close" menu, "Update" menu, "Download Diff", "Add General Comment", and two tabs: "Reviews" and "Diff".

The existing system is, let’s be honest, a bit of a mess. It grew organically, and we kept bolting things onto the design. There are class-based review request actions, dictionary-based review request actions, two forms of header actions, and several other purpose-built types. Keeping this maintainable has been a problem.

So this is finally getting a major overhaul. The new design is a lot more reasonable for both us and extension authors to work with. With this, we’re aiming for:

  • Better keyboard shortcuts throughout the product.
  • Improved accessibility.
  • Newer UI features like a possible Command-K bar (a sort of command-line-in-browser interface, similar to macOS Spotlight, Alfred, and other tools).

Once this is further along, we’ll have more to show off.

Looking Toward Review Board 6

With Review Board 6, we’re heavily focusing on improvements to the review process. There’s more to talk about, but we’ll save those for a future ChangeLog (available on this blog, Reddit, Mastodon, Twitter, or Facebook).

We’re aiming to for a mid-2023 release date for Review Board 6. This is a shorter release cycle than most of our large releases, and that’s the plan going forward. We want to get new features our faster, with smaller, focused releases.

Read More

Djblets 3.1: Token Deprecations and API Fixes

We’ve released Djblets 3.1, our collection of production-quality add-ons for Django.

This release features:

  • Ability to deprecate token generators
  • Deprecated token information in the API
  • Fixes for URI template name collisions in the API
  • Fixes for generating the new API tokens introduced in Djblets 3
  • Python 3 type hints for the djblets.registries, djblets.secrets, and djblets.siteconfig models

For complete details, see the release notes.

Read More

Django Evolution 2.2: Django 3.2-4.1 Support

Django Evolution 2.2 is a major feature release, offering new database features, improved compatibility, and several bug fixes.

Django Evolution is our alternative database migration library for Django, which supports a wide range of Django versions and optimized application of database changes. It targets self-managed applications, like Review Board, which may potentially go several releases between upgrades.

The highlights include:

  • Compatibility with Django 1.6 through 4.1, and Python 2.7 through 3.11
  • Support for conditions, expressions, opclasses, and field lists in Django’s Index classes.
  • Ability to change field types in ChangeField.
  • Improved settings for defining project-provided custom evolutions.
  • Bug fixes for MySQL compatibility, edge cases in SQL generation for indexes, and Python 3.10 compatibility.

The release notes cover the full list of changes in Django Evolution 2.2.

Read More

RBTools 3.1.2, Power Pack 5.1.1

Today, we’re bringing two new releases of RBTools and Power Pack, focusing on stability and feature improvements.

RBTools 3.1.2 Highlights

  • Now supports the upcoming Python 3.11.
  • Added back directory change information to diffs for ClearCase and VersionVault, and fixed problems posting symlinks.
  • Fixed several issues generating Perforce diffs, especially on Python 3.
  • Fixed applied patches on Subversion.

To learn more about this release, see the RBTools 3.1.2 release notes.

Power Pack 5.1.1 Highlights

  • Added support for showing changes to directories when using ClearCase or VersionVault
  • Fixed broken repository configuration forms when selecting Cliosoft SOS on Review Board 4.0.3 or older.

This upgrade is available for all existing Power Pack users.

To learn more about this release, see the Power Pack 5.1.1 release notes.

Read More

beanbag-docutils 2.0: Python 3.11, New Sphinx Autodoc Features

beanbag-docutils is a set of extensions to the Sphinx ReStructuredText-based documentation system used by our products to help generate better documentation. Amongst other enhancements, it provides:

  • A parser for the Beanbag docstring format, a variation on the Google docstring format, which we use for Python and JavaScript documentation
  • Enhancements for Sphinx’s intersphinx system to provide per-page intersphinx resolution options (useful for pages, such as release notes, that need to link to different versions of the same docs, such as Django or Python)
  • Enhancements to ReStructuredText references to let a reference name span lines (useful for long Python/JavaScript module/class names)
  • Linking code references to GitHub documentation
  • High-DPI image embedding
  • A role for HTTP status codes

Today’s release of beanbag-docutils 2.0 features:

  • Python 3.11 support, and the removal of Python 2.7
  • Improved Sphinx configuration defaults when using autodoc_utils.
  • New autodoc sections for documenting attribute/property types (Type:), dictionary keys (Keys:), and tuples (Tuple:)
  • Fixes for lists within version sections (Version Added:, Version Changed:, and Deprecated:)
  • Fixes and improvements for linking to code on GitHub

See the release notes for the full list of changes.

Read More

Djblets 2.3: Preparing for the Future

Djblets 2.3 is now out. This release adds compatibility fixes for Python 3.10 and gets our code ready to move to newer dependencies.

Highlights include:

  • Python 3.10 compatibility shims for Django 1.11.
  • Modern Django middleware support for extensions.
  • Babel 7.x for building extension static media files.
  • Full compatibility with Python-Markdown 2.x.
  • Support for caching data in cache_memoize() without needing to wrap in a list or string.

We’re getting 3.x ready for release. This will move the codebase to require Python 3.7+ and Django 3.2 LTS, finally bringing support for modern codebases.

See the release notes for the full list of changes.

Read More

Django Evolution 2.1.3: Evolution and compatibility fixes

Django Evolution 2.1.3 a small but important bug fix release that addresses issues with Python 3.10, mysqlclient, and evolving very old databases.

Compatibility Fixes

Python 3.10 removed some deprecated imports from collections, which Django 2.0 and older depend on. When using this combination of versions, Django Evolution will bring back those legacy imports, allowing Django to work again.

mysqlclient also received a similar fix. Django 1.11 and older depended on some unintentional functionality, which mysqlclient maintained until the 2.1 release. We now patch these versions of Django at runtime to continue working.

Upgrade Fixes

Two important issues affecting upgrades were addressed:

  1. Django Evolution no longer tries to apply evolutions to models that were just introduced. This was a regression from previous releases.
  2. When upgrading from very old databases, some state for a model’s unique_together index couldn’t be compared properly, causing issues applying some upgrades. The old format for this state is now taken into account during comparison.

Coming Up…

We’re preparing Django Evolution 2.2, which will support all versions of Django up through 4.0. This should be coming soon.

In the meantime, check out the release notes for the full changes, including other fixes in this release.

Read More

kgb 7.0: Pytest, Python 3.10, and more

kgb 7.0 has been released with a handful of new features:

  • Python 3.10 support
  • Support for pytest, and other non-unittest-based test frameworks
  • Snake-case and standalone assertion methods
  • Workarounds for spying on methods with poorly-implemented decorators

It also drops official support for Python 2.6 and 3.4-3.5 (though these should still work for now, if you need them).

pytest

kgb now provides a spy_agency fixture for pytest unit tests. This will set up a SpyAgency for you, letting you spy on functions and assert calls. For example:

def test_doomsday_device(spy_agency):
    device = DoomsdayDevice()
    spy_agency.spy_on(device.destroy_reality, call_original=False)

    device.trigger_the_event()

    spy_agency.assert_spy_called(device.destroy_reality)

The SpyAgency will be managed for the lifetime of the test, removing spies upon completion.

Snake-case and standalone assertion methods

We’ve provided snake_case versions of all the assertion methods, making for more natural tests. For instance, you can use assert_spy_called_with() instead of assertSpyCalledWith(). The old camelCase versions will continue to exist, though.

You can also call assertion methods without needing to mix in a SpyAgency into your test. Just import from kgb.asserts. This is useful if you have a need to spy on methods and assert them within non-unit test code, or without access to a SpyAgency. For example:

from kgb.asserts import assert_spy_called_with

def check_connection_state(api_connection):
    assert_spy_called_with(api_connection.make_request,
                           url='https://middleman.zyx',
                           method='POST')

Workarounds for bad decorators

Before, if you were trying to spy on a method (particularly unbound methods) wrapped in a decorator, and that decorator didn’t preserve the function’s original name, you’d hit an error looking up the method.

You can now work around this by passing the original function name when setting up a spy. For example:

def bad_decorator(func):
    def _wrap(*args, **kwargs):
        return func(*args, **kwargs)

    return _wrap

class BadClass:
    @bad_decorator
    def good_func(self):
        return 42

def test_good_func(spy_agency):
    spy_agency.spy_on(BadClass.good_func,
                      owner=BadClass,
                      func_name='good_func')

kgb will try to detect when you need this and emit a warning during the test.

Get started with kgb 7.0

See the release notes for the full list of changes.

You can install kgb today through pip:

$ pip install -U kgb

Visit our kgb documentation to see how to use kgb in your projects.

Read More