From 905255baf73a5072c5d5de0e9ab8c121ce0d5a69 Mon Sep 17 00:00:00 2001 From: Martin Tzvetanov Grigorov Date: Thu, 22 Jan 2026 08:54:26 +0200 Subject: [PATCH] chore: Format Python code to make its linter happy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/apache/avro/actions/runs/21238630219/job/61111610761 ``` lint: commands[1]> black --check . would reformat /home/runner/work/avro/avro/lang/py/avro/constants.py would reformat /home/runner/work/avro/avro/lang/py/avro/__main__.py would reformat /home/runner/work/avro/avro/lang/py/avro/datafile.py would reformat /home/runner/work/avro/avro/lang/py/avro/name.py would reformat /home/runner/work/avro/avro/lang/py/avro/test/test_schema.py Oh no! 💥 💔 💥 5 files would be reformatted, 36 files would be left unchanged. lint: exit 1 (2.52 seconds) /home/runner/work/avro/avro/lang/py> black --check . pid=3003 lint: FAIL code 1 (9.68=setup[6.91]+cmd[0.25,2.52] seconds) evaluation failed :( (9.71 seconds) ``` Reformatted the code by temporary removing `check` in `black check .` in tox.ini, running `./build.sh lint`, restore `check` --- lang/py/avro/__main__.py | 1 + lang/py/avro/constants.py | 1 - lang/py/avro/datafile.py | 1 + lang/py/avro/name.py | 1 + lang/py/avro/test/test_schema.py | 30 ++++++++++-------------------- 5 files changed, 13 insertions(+), 21 deletions(-) diff --git a/lang/py/avro/__main__.py b/lang/py/avro/__main__.py index 44fda88252b..f1e1499f1f0 100755 --- a/lang/py/avro/__main__.py +++ b/lang/py/avro/__main__.py @@ -17,6 +17,7 @@ # See the License for the specific language governing permissions and # limitations under the License. """Command line utility for reading and writing Avro files.""" + import argparse import csv import functools diff --git a/lang/py/avro/constants.py b/lang/py/avro/constants.py index 6bdf5a9b4b0..cef9e85daf8 100644 --- a/lang/py/avro/constants.py +++ b/lang/py/avro/constants.py @@ -19,7 +19,6 @@ """Contains Constants for Python Avro""" - DATE = "date" DECIMAL = "decimal" TIMESTAMP_MICROS = "timestamp-micros" diff --git a/lang/py/avro/datafile.py b/lang/py/avro/datafile.py index 541fe5376ec..8a5ce7b17f3 100644 --- a/lang/py/avro/datafile.py +++ b/lang/py/avro/datafile.py @@ -22,6 +22,7 @@ https://avro.apache.org/docs/current/spec.html#Object+Container+Files """ + import io import json import warnings diff --git a/lang/py/avro/name.py b/lang/py/avro/name.py index 0d28338de59..898e53a4906 100644 --- a/lang/py/avro/name.py +++ b/lang/py/avro/name.py @@ -18,6 +18,7 @@ # limitations under the License. """Contains the Name classes.""" + from typing import TYPE_CHECKING, Dict, Optional from avro.constants import PRIMITIVE_TYPES diff --git a/lang/py/avro/test/test_schema.py b/lang/py/avro/test/test_schema.py index 85d9f8db839..c8d94811a21 100644 --- a/lang/py/avro/test/test_schema.py +++ b/lang/py/avro/test/test_schema.py @@ -745,8 +745,7 @@ class TestMisc(unittest.TestCase): def test_correct_recursive_extraction(self): """A recursive reference within a schema should be the same type every time.""" - s = avro.schema.parse( - """{ + s = avro.schema.parse("""{ "type": "record", "name": "X", "fields": [{ @@ -756,8 +755,7 @@ def test_correct_recursive_extraction(self): "name": "Y", "fields": [{"name": "Z", "type": "X"}]} }] - }""" - ) + }""") t = avro.schema.parse(str(s.fields[0].type)) # If we've made it this far, the subschema was reasonably stringified; it ccould be reparsed. self.assertEqual("X", t.fields[0].type.name) @@ -1186,12 +1184,10 @@ def test_whitespace(self): """ Eliminate all whitespace in JSON outside of string literals. """ - s = avro.schema.parse( - """{"type": "fixed", + s = avro.schema.parse("""{"type": "fixed", "size": 16, "name": "md5"} - """ - ) + """) self.assertEqual( s.canonical_form, self.compact_json_string({"name": "md5", "type": "fixed", "size": 16}), @@ -1270,8 +1266,7 @@ def test_union(self): self.assertEqual(s.canonical_form, '["string","null","long"]') def test_large_record_handshake_request(self): - s = avro.schema.parse( - """ + s = avro.schema.parse(""" { "type": "record", "name": "HandshakeRequest", @@ -1289,8 +1284,7 @@ def test_large_record_handshake_request(self): } ] } - """ - ) + """) self.assertEqual( s.canonical_form, ( @@ -1303,8 +1297,7 @@ def test_large_record_handshake_request(self): ) def test_large_record_handshake_response(self): - s = avro.schema.parse( - """ + s = avro.schema.parse(""" { "type": "record", "name": "HandshakeResponse", @@ -1327,8 +1320,7 @@ def test_large_record_handshake_response(self): "name": "meta", "type": ["null", {"type": "map", "values": "bytes"}]}] } - """ - ) + """) self.assertEqual( s.canonical_form, ( @@ -1343,8 +1335,7 @@ def test_large_record_handshake_response(self): ) def test_large_record_interop(self): - s = avro.schema.parse( - """ + s = avro.schema.parse(""" { "type": "record", "name": "Interop", @@ -1391,8 +1382,7 @@ def test_large_record_interop(self): } ] } - """ - ) + """) self.assertEqual( s.canonical_form, (