This is an automated email from the ASF dual-hosted git repository.
rskraba pushed a commit to branch branch-1.12
in repository https://gitbox.apache.org/repos/asf/avro.git
The following commit(s) were added to refs/heads/branch-1.12 by this push:
new 0ef2355267 [python][hotfix][1.12] Fix python formatting (#3723)
0ef2355267 is described below
commit 0ef23552679cef131dc1174ed5bd5edc60a581f5
Author: Ryan Skraba <[email protected]>
AuthorDate: Mon Apr 6 14:53:31 2026 +0200
[python][hotfix][1.12] Fix python formatting (#3723)
* [python] Fix python formatting
* Include typechecks setup
---
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 ++++++++++--------------------
lang/py/setup.cfg | 1 +
6 files changed, 14 insertions(+), 21 deletions(-)
diff --git a/lang/py/avro/__main__.py b/lang/py/avro/__main__.py
index 44fda88252..f1e1499f1f 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 6bdf5a9b4b..cef9e85daf 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 541fe5376e..8a5ce7b17f 100644
--- a/lang/py/avro/datafile.py
+++ b/lang/py/avro/datafile.py
@@ -22,6 +22,7 @@ Read/Write Avro File Object Containers.
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 0d28338de5..898e53a490 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 85d9f8db83..c8d94811a2 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 @@ class TestMisc(unittest.TestCase):
"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 @@ class CanonicalFormTestCase(unittest.TestCase):
"""
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 @@ class CanonicalFormTestCase(unittest.TestCase):
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 @@ class CanonicalFormTestCase(unittest.TestCase):
}
]
}
- """
- )
+ """)
self.assertEqual(
s.canonical_form,
(
@@ -1303,8 +1297,7 @@ class CanonicalFormTestCase(unittest.TestCase):
)
def test_large_record_handshake_response(self):
- s = avro.schema.parse(
- """
+ s = avro.schema.parse("""
{
"type": "record",
"name": "HandshakeResponse",
@@ -1327,8 +1320,7 @@ class CanonicalFormTestCase(unittest.TestCase):
"name": "meta",
"type": ["null", {"type": "map", "values": "bytes"}]}]
}
- """
- )
+ """)
self.assertEqual(
s.canonical_form,
(
@@ -1343,8 +1335,7 @@ class CanonicalFormTestCase(unittest.TestCase):
)
def test_large_record_interop(self):
- s = avro.schema.parse(
- """
+ s = avro.schema.parse("""
{
"type": "record",
"name": "Interop",
@@ -1391,8 +1382,7 @@ class CanonicalFormTestCase(unittest.TestCase):
}
]
}
- """
- )
+ """)
self.assertEqual(
s.canonical_form,
(
diff --git a/lang/py/setup.cfg b/lang/py/setup.cfg
index 46f1a84f2a..18e68739ae 100644
--- a/lang/py/setup.cfg
+++ b/lang/py/setup.cfg
@@ -75,6 +75,7 @@ avro.tether =
[options.extras_require]
snappy = python-snappy
zstandard = zstandard
+mypy = mypy
[aliases]
dist = sdist --dist-dir ../../dist/py