From 1794344306425be407565eb978316827f33a984b Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 5 May 2022 13:40:24 +0100 Subject: [PATCH 1/2] Update test dependencies to latest versions --- requirements_for_test.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/requirements_for_test.txt b/requirements_for_test.txt index 6b37f9ee3..3f4e92055 100644 --- a/requirements_for_test.txt +++ b/requirements_for_test.txt @@ -1,15 +1,15 @@ -r requirements.txt isort==5.10.1 -pytest==7.1.1 +pytest==7.1.2 pytest-env==0.6.2 pytest-mock==3.7.0 pytest-xdist==2.5.0 -beautifulsoup4==4.10.0 -freezegun==1.2.0 +beautifulsoup4==4.11.1 +freezegun==1.2.1 flake8==4.0.1 -flake8-bugbear==22.3.23 -flake8-print==4.0.0 -moto==3.1.4 +flake8-bugbear==22.4.25 +flake8-print==5.0.0 +moto==3.1.7 requests-mock==1.9.3 # used for creating manifest file locally jinja2-cli[yaml]==0.8.2 From 7a0ba988bbaa7482da69a081fd75afd58169fec2 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 5 May 2022 13:50:29 +0100 Subject: [PATCH 2/2] Update flake8 error code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit flake8-print moved its namespace from `T0*` to `T2*` as a breaking change in version 5.0.0 – see https://github.com/jbkahn/flake8-print#500---2022-04-30 --- .../create-broadcast-areas-db.py | 34 +++++++++---------- app/broadcast_areas/populations.py | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/app/broadcast_areas/create-broadcast-areas-db.py b/app/broadcast_areas/create-broadcast-areas-db.py index 6c79670fb..9e5cccbc0 100755 --- a/app/broadcast_areas/create-broadcast-areas-db.py +++ b/app/broadcast_areas/create-broadcast-areas-db.py @@ -64,7 +64,7 @@ def clean_up_invalid_polygons(polygons, indent=" "): )).simplify(0) if simplified_polygon.is_valid: - print( # noqa: T001 + print( # noqa: T201 f"{indent}Polygon {index + 1}/{len(polygons)} is valid" ) yield simplified_polygon @@ -76,12 +76,12 @@ def clean_up_invalid_polygons(polygons, indent=" "): # don’t have an area. They wouldn’t contribute to a broadcast # so we can ignore them. if simplified_polygon.area == 0: - print( # noqa: T001 + print( # noqa: T201 f"{indent}Polygon {index + 1}/{len(polygons)} has 0 area, skipping" ) continue - print( # noqa: T001 + print( # noqa: T201 f"{indent}Polygon {index + 1}/{len(polygons)} needs fixing..." ) @@ -107,7 +107,7 @@ def clean_up_invalid_polygons(polygons, indent=" "): assert fixed_polygon.is_valid assert isclose(fixed_polygon.area, shapely_polygon.area, rel_tol=0.001) - print( # noqa: T001 + print( # noqa: T201 f"{indent}Polygon {index + 1}/{len(polygons)} fixed!" ) @@ -135,7 +135,7 @@ def polygons_and_simplified_polygons(feature): 'Polygon of 0 size found' ) - print( # noqa: T001 + print( # noqa: T201 f' Original:{full_resolution.point_count: >5} points' f' Smoothed:{smoothed.point_count: >5} points' f' Simplified:{simplified.point_count: >4} points' @@ -169,7 +169,7 @@ def estimate_number_of_smartphones_in_area(country_or_ward_code): # We don’t have population figures for wards of the City of # London. We’ll leave it empty here and estimate on the fly # later based on physical area. - print(' Population: N/A') # noqa: T001 + print(' Population: N/A') # noqa: T201 return None # For some reason Bryher is the only ward missing population data, so we @@ -264,8 +264,8 @@ def add_test_areas(): f_id = feature["properties"]['id'] f_name = feature["properties"]['name'] - print() # noqa: T001 - print(f_name) # noqa: T001 + print() # noqa: T201 + print(f_name) # noqa: T201 feature, _, utm_crs = polygons_and_simplified_polygons( feature["geometry"] @@ -296,8 +296,8 @@ def add_countries(): f_id = feature["properties"]['ctry19cd'] f_name = feature["properties"]['ctry19nm'] - print() # noqa: T001 - print(f_name) # noqa: T001 + print() # noqa: T201 + print(f_name) # noqa: T201 feature, simple_feature, utm_crs = ( polygons_and_simplified_polygons(feature["geometry"]) @@ -336,8 +336,8 @@ def _add_electoral_wards(dataset_id): ward_name = feature["properties"]["wd20nm"] ward_id = "wd20-" + ward_code - print() # noqa: T001 - print(ward_name) # noqa: T001 + print() # noqa: T201 + print(ward_name) # noqa: T201 try: la_id = "lad20-" + ward_code_to_la_id_mapping[ward_code] @@ -358,7 +358,7 @@ def _add_electoral_wards(dataset_id): ]) except KeyError: - print("Skipping", ward_code, ward_name) # noqa: T001 + print("Skipping", ward_code, ward_name) # noqa: T201 rtree_index_path.open('wb').write(pickle.dumps(rtree_index)) repo.insert_broadcast_areas(areas_to_add, keep_old_polygons) @@ -371,8 +371,8 @@ def _add_local_authorities(dataset_id): la_id = feature["properties"]["LAD20CD"] group_name = feature["properties"]["LAD20NM"] - print() # noqa: T001 - print(group_name) # noqa: T001 + print() # noqa: T201 + print(group_name) # noqa: T201 group_id = "lad20-" + la_id @@ -424,7 +424,7 @@ def _add_counties_and_unitary_authorities(dataset_id): # cheeky global variable keep_old_polygons = sys.argv[1:] == ['--keep-old-polygons'] -print('keep_old_polygons: ', keep_old_polygons) # noqa: T001 +print('keep_old_polygons: ', keep_old_polygons) # noqa: T201 repo = BroadcastAreasRepository() @@ -443,7 +443,7 @@ most_detailed_polygons = formatted_list( after_each='', ) -print( # noqa: T001 +print( # noqa: T201 '\n' 'DONE\n' f' Processed {len(point_counts):,} polygons.\n' diff --git a/app/broadcast_areas/populations.py b/app/broadcast_areas/populations.py index 39db91786..19b03208b 100644 --- a/app/broadcast_areas/populations.py +++ b/app/broadcast_areas/populations.py @@ -55,7 +55,7 @@ def estimate_number_of_smartphones_for_population(population): total_population = sum(dict(population).values()) total_phones = sum(smartphone_ownership_for_area_by_age_range.values()) - print( # noqa: T001 + print( # noqa: T201 f' Population:{total_population: 11,.0f}' f' Phones:{total_phones: 11,.0f}' )