Projet

Général

Profil

0021-misc-fix-consider-using-dict-items-pylint-error-6209.patch

Lauréline Guérin, 22 mars 2022 10:30

Télécharger (5,01 ko)

Voir les différences:

Subject: [PATCH 21/65] misc: fix consider-using-dict-items pylint error
 (#62099)

 passerelle/apps/sp_fr/models.py            | 10 +++++-----
 passerelle/base/models.py                  |  4 ++--
 passerelle/contrib/toulouse_smart/views.py |  4 ++--
 passerelle/utils/json.py                   |  3 +--
 tests/test_solis.py                        |  6 ++----
 5 files changed, 12 insertions(+), 15 deletions(-)
passerelle/apps/sp_fr/models.py
266 266
                    if len(doc_files) != 1:
267 267
                        return False, 'too many/few doc files found: %s' % doc_files
268 268

  
269
                    for key in attachments:
270
                        if len(attachments[key]) > 1:
271
                            return False, 'too many attachments of kind %s: %r' % (key, attachments[key])
272
                        name = attachments[key][0]
273
                        with archive.open(attachments[key][0]) as zip_fd:
269
                    for key, attachment in attachments.items():
270
                        if len(attachment) > 1:
271
                            return False, 'too many attachments of kind %s: %r' % (key, attachment)
272
                        name = attachment[0]
273
                        with archive.open(name) as zip_fd:
274 274
                            content = zip_fd.read()
275 275
                        attachments[key] = {
276 276
                            'filename': name,
passerelle/base/models.py
433 433
        }
434 434
        init_kwargs.update(kwargs)
435 435
        if instance:
436
            for key in init_kwargs:
437
                setattr(instance, key, init_kwargs[key])
436
            for key, value in init_kwargs.items():
437
                setattr(instance, key, value)
438 438
        else:
439 439
            instance = cls(**init_kwargs)
440 440
        concrete_fields = [
passerelle/contrib/toulouse_smart/views.py
68 68
        response = HttpResponse(content_type='application/zip')
69 69
        response['Content-Disposition'] = 'attachment; filename=blocks.zip'
70 70
        with zipfile.ZipFile(response, mode='w') as zip_file:
71
            for name in files:
72
                zip_file.writestr(name, files[name])
71
            for name, f in files.items():
72
                zip_file.writestr(name, f)
73 73

  
74 74
        return response
passerelle/utils/json.py
128 128
            for subschema in schema['oneOf']:
129 129
                for key, schema in helper(prefix, subschema):
130 130
                    schemas_by_keys.setdefault(key, []).append(schema)
131
            for key in schemas_by_keys:
132
                schemas = schemas_by_keys[key]
131
            for key, schemas in schemas_by_keys.items():
133 132
                if len(schemas) > 1:
134 133
                    yield key, {'oneOf': schemas}
135 134
                else:
tests/test_solis.py
349 349
            assert SolisAPALink.objects.get(name_id=NAMEID, user_id='42').text == 'Mme Pecile PEPONE (NPYNEZ)'
350 350

  
351 351
    # get all kind of informations
352
    for apa_endpoint in APAINFOS:
352
    for apa_endpoint, content in APAINFOS.items():
353 353
        with mock.patch('passerelle.utils.Request.get') as requests_get:
354 354
            with mock.patch('passerelle.utils.Request.post') as requests_post:
355 355
                requests_post.return_value = tests.utils.FakedResponse(content=APATOKEN, status_code=200)
......
359 359
                assert resp.json['err'] == 1
360 360

  
361 361
                endpoint = endpoint_base + '?name_id=%s&user_id=53&information=%s' % (NAMEID, apa_endpoint)
362
                requests_get.return_value = tests.utils.FakedResponse(
363
                    content=APAINFOS[apa_endpoint], status_code=200
364
                )
362
                requests_get.return_value = tests.utils.FakedResponse(content=content, status_code=200)
365 363
                resp = app.get(endpoint, status=200)
366 364
                assert requests_post.call_count == 1  # get a token
367 365
                assert requests_get.call_count == 1  # get informations
368
-