7 Commits

Author SHA1 Message Date
Akihiro Motoki
e5d09edc20 Use python3-style super()
In python3, super() does not always require a class and self reference.
In other words, super() is enough for most cases.
This is much simpler and it is time to switch it to the newer style.

pylint provides a check for this.
Let's enable 'super-with-arguments' check.

NOTE: _prepare_mappings() method of FormRegion in
openstack_dashboard/test/integration_tests/regions/forms.py is refactored.
super() (without explicit class and self referece) does not work when
a subclass method calls a same method in a parent class multiple times.
It looks better to prepare a separate method to provide a common logic.

Change-Id: Id9512a14be9f20dbd5ebd63d446570c7b7c825ff
2020-10-15 14:37:20 +09:00
Ivan Kolodyazhny
d870b40583 Remove six usage from openstack_dashboard package
We don't support Python 2 anymore so we don't need this
compatibility library.

six.reraise usages are left as is until it'll be moved to some
base lib like oslo.utils to not re-implenent this method in
Horizon.

This patch also removes Python2-specific base test case methods
assertItemsEqual and assertNotRegexpMatches in flavor of new
Python 3 analogues.

Change-Id: I26a59176be9e9f213128e4945a58b9459334b626
2020-01-15 12:47:48 +02:00
Akihiro Motoki
7c585e2643 pylint: fix some refactor recommendations
openstack_dashboard/dashboards/project/security_groups/forms.py:393:13: R1714: Consider merging these comparisons with "in" to "rule_menu in ('tcp', 'udp')" (consider-using-in)
openstack_dashboard/api/rest/json_encoder.py:61:15: R0124: Redundant comparison - o != o (comparison-with-itself)
openstack_dashboard/api/keystone.py:904:15: R1714: Consider merging these comparisons with "in" to 'default in (role.id, role.name)' (consider-using-in)
horizon/templatetags/truncate_filter.py:30:7: R1716: Simplify chained comparison between the operands (chained-comparison)

Change-Id: I6cf8602f88c4027ff12aaa4ea5a9f2069ae2e2a6
2019-01-17 00:44:19 +09:00
Akihiro Motoki
b9d0243c33 Fix H405 (multi line docstring) warnings (openstack_dashboard)
H405: multi line docstring summary not separated with an empty line

Closes-Bug: #1696996

Change-Id: Id895695663b19522d9cdc22f8b012e49680d708b
2017-06-09 16:05:31 +00:00
Richard Jones
b05658735b Enable Python 3.5 testing and fix tests
Fixes to a couple of places to make the python 3.5 tests pass.

Change-Id: I3f4b73b24fbe336ac6c80b7aa224a830ab7e36a6
2016-09-06 14:41:15 +10:00
Victor Stinner
ee426f91d6 py3: Add json attribute to HTTP response objects
Add a json attribute to CreatedResponse and JSONResponse of
openstack_dashboard.api.rest.utils.

This patch changes unit tests: they now compare deserialized JSON
data instead of comparing the serialized JSON data which depends on
the exact hash function

This change makes the code more readable, but it was written to port
openstack_dashboard to Python 3. On Python 3, the hash function is
now randomized by default, so dictionary items are serialized in a
random order by JSON. Moreover, the hash function is different on
Python 2 and Python 3, so setting PYTHONHASHSEED=0 in tox.ini is not
enough to have a reliable JSON serialized ouput in all cases.

Fix also NaNJSONEncoder: On Python 3, don't try to decode bytes from
the encoder encoding, since the JSON encoder has no more encoding on
Python 3: it produces an Unicode string.

Partial-Implements: blueprint porting-python3
Change-Id: I8503ee530d4122b2ce733d02023454796934c8e6
Co-Authored-By: Richard Jones <r1chardj0n3s@gmail.com>
2015-10-06 14:17:19 +02:00
Timur Sufiev
5398de264d Enable Launch Instance NG for the case when Nova quotas are disabled
Do this by representing every float('inf') python numeric as a 1e+999
JSON token - this way Javascript JSON.parse() correctly transforms it
to the Javascript Infinity object. The infinity value corresponds to
disabled limits.

The logic of representing infinity values as 1e+999 tokens is
implemented by means of custom `NaNJSONEncoder` which overrides
`iterencode` method of its `json.JSONEncoder` ancestor. Due to the
fact that the ancestor method could take an advantage of
`c_make_encoder` function (which is implemented in C) - and thus could
be much faster, I'm using the custom encoder only where it's really
needed, to not hamper Horizon performance.

Rewrite pie-chart directive rendering according to
https://invis.io/A4445BDSF

Change-Id: If498d9ccd5f0144c9e78ae58583ede2c1cf83f0b
Closes-Bug: #1482705
2015-09-18 17:55:59 +03:00