'Unclear suggestion: "This dictionary could be written as dictionary litteral."

I'm using PyCharm to write automated tests for an API. PyCharm highlights one line in my tests and suggests:

This dictionary could be written as dictionary litteral.

Is there a better a "style" to do this to make this message disappear?

def test_get_products_combination_2(self):
    """
    TC-586:GET Products - combination 2 valid
    """
    params = {} # <--- this line is highlighted with the message above
    params["start_at_document"] = "100"
    params["document_limit"] = "2"
    path = "/v1/users/%s/products" % self.user_id
    r = self.client.request(path, params)
    self.assertEqual(r.status_code, 200)


Solution 1:[1]

If you change params to dictionary literal it should fix the warning:

params = {
    "start_at_document": "100",
    "document_limit": "2"
}

Solution 2:[2]

PyCharm actually supports this refactoring right out of box. Just navigate on the warning line, then press Alt+Enter; a popup menu appears; the first item says "Replace dictionary creation"; so press Enter again to get

params = {"start_at_document": "100", "document_limit": "2"}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 niemmi
Solution 2 Antti Haapala -- Слава Україні