Commit Graph

16 Commits

Author SHA1 Message Date
Ter Chrng Ng
7bc3dedc53 Fix conflict with RLock
Summary: Also reported https://bitbucket.org/tortoisehg/thg/issues/4684/change-in-autocomplete-behavior

Reviewed By: farnz

Differential Revision: D8988988

fbshipit-source-id: 28cb99928a2f4699b144e0a9e30a08851e7ebd19
2018-07-25 10:21:05 -07:00
Jun Wu
584656dff3 codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).

Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.

Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.

An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.

As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.

Reviewed By: wez, phillco, simpkins, pkaush, singhsrb

Differential Revision: D8173629

fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-25 22:17:29 -07:00
Jun Wu
5c05ef8327 extensions: forbid "foo=" from importing foreign mercurial modules
Summary: This avoids issues where a wrong (outside the repo) extension was used.

Test Plan: Ran all tests

Reviewers: durham, #mercurial

Reviewed By: durham

Subscribers: durham

Differential Revision: https://phabricator.intern.facebook.com/D6690534

Signature: 6690534:1515632034:1353c9272650cf925dd299d252592afd52970e98
2018-01-09 17:06:09 -08:00
Augie Fackler
33d314f3e6 demandimportpy3: update to pass import checker 2017-08-22 14:14:34 -04:00
Jun Wu
3e05e789bc demandimport: disable if chg is being used
In chg's case, making modules lazily loaded could actually slow down things
since chg pre-imports them. Therefore disable demandimport if chg is being
used.

This is not done by setting `HGDEMANDIMPORT` chg client-side because that
has side-effects on child processes (hooks, etc).

Differential Revision: https://phab.mercurial-scm.org/D351
2017-08-16 10:44:06 -07:00
Jun Wu
e60bc9fd17 demandimport: move HGDEMANDIMPORT test to __init__.py
The logic is now shared between demandimport{2,3}.

Differential Revision: https://phab.mercurial-scm.org/D445
2017-08-18 11:08:17 -07:00
Yuya Nishihara
0d4ca251b9 demandimport: prefer loaded module over package attribute (issue5617)
In general, the attribute of the same name is overwritten by executing an
import statement.

  import a.b
  print(a.b.c)  # 'c' of a/b/__init__.py
  from a.b.c import d
  print(a.b.c)  # a/b/c.py

However, this appears not true for the scenario described in the test case,
and surprisingly, "from a.b.c import d" works even if "a.b.c" is not a module.

This patch works around the problem by taking the right module from sys.modules
if available.
2017-07-16 17:38:39 +09:00
Yuya Nishihara
7c2ef4a52e demandimport: drop Py3 workarounds from Py2 implementation 2017-07-16 17:19:22 +09:00
Yuya Nishihara
99466473c5 demandimport: drop hack for old Pythons which had no level argument
_import() was added by 1538e0df23b4, but it is identical to _origimport()
now.
2017-07-16 17:16:32 +09:00
Yuya Nishihara
07ba7d360b demandimport: stop overriding __getattribute__()
Proxy __dict__ and __doc__ explicitly instead.

I'm not sure which is less evil, but this seems slightly simpler than hooking
all attribute accesses.
2017-04-28 00:01:22 +09:00
Yuya Nishihara
7cd4cd9753 demandimport: look for 'mod' suffix as alternative name for module reference
It's widely used in our codebase.
2017-04-28 23:46:16 +09:00
Yuya Nishihara
3bbb35ccf6 demandimport: insert empty line per method
_demandmod class is getting bigger, and I don't want to put more things in
a dense form.
2017-05-01 14:26:56 +09:00
Yuya Nishihara
8bad75346f demandimport: strictly compare identity of proxy object
This looks better, and __eq__() may be overridden in an undesired way.
2017-05-01 13:43:31 +09:00
Siddharth Agarwal
71d917f14d demandimport: add python 3 implementation
This implementation uses the new importlib finder/loader functionality
available in Python 3.5 and up.

# no-check-commit
2017-05-21 12:23:04 -07:00
Siddharth Agarwal
8ffb99bcb0 demandimport: move ignore list to __init__.py
We're going to use the same ignore list for Python 3.
2017-05-21 12:10:53 -07:00
Siddharth Agarwal
a41c665cd6 demandimport: move to separate package
In Python 3, demand loading is per-package. Keeping demandimport in the
mercurial package would disable demand loading for any modules in
mercurial.
2017-05-21 12:10:53 -07:00