Mercurial > hg
view tests/test-empty.t @ 46807:2c0e35f6957a
typing: mark the argument to mercurial.i18n.gettext() non-Optional
Few if any of the callers are handling a `None` return, which is making pytype
complain. I tried adding @overload definitions to indicate the bytes -> bytes
and None -> None relationship, but pytype doesn't seem to apply that to `_()`
through the function assignment. What did work was to change `_()` into its own
function that called `gettext()`, but that has an extra function call overhead.
Even putting that function into an `if pycompat.TYPE_CHECKING` block and leaving
the existing assignments in the `else` block caused pytype to lose track of the
@overloads.
At that point, I simply gave up. PyCharm doesn't like that it can return None,
given the new type hints, but pytype doesn't complain about this nor does it
see any callers passing None. The most important thing here is to catch str
being passed anyway.
Differential Revision: https://phab.mercurial-scm.org/D10235
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 18 Mar 2021 23:41:00 -0400 |
parents | 95a615dd77bf |
children | d1c1fd7ac46d |
line wrap: on
line source
Create an empty repo: $ hg init a $ cd a Try some commands: $ hg log $ hg grep wah [1] $ hg manifest $ hg verify checking changesets checking manifests crosschecking files in changesets and manifests checking files checked 0 changesets with 0 changes to 0 files Check the basic files created: $ ls .hg 00changelog.i cache requires store wcache Should be empty: $ ls .hg/store Poke at a clone: $ cd .. $ hg clone a b updating to branch default 0 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd b $ hg verify checking changesets checking manifests crosschecking files in changesets and manifests checking files checked 0 changesets with 0 changes to 0 files $ ls .hg 00changelog.i cache hgrc requires store Should be empty: $ ls .hg/store $ cd ..