make it more clear which are public and private APIs
MODIFY
fastavro/_validation_py.py
fastavro/_validation_py.py
@@ -7,8 +7,7 @@ from fastavro.const import (
INT_MAX_VALUE, INT_MIN_VALUE, LONG_MAX_VALUE, LONG_MIN_VALUE
)
from ._validate_common import ValidationError, ValidationErrorData
-from .schema import extract_record_type, UnknownType
-from .schema import _schema_name as schema_name
+from .schema import extract_record_type, UnknownType, schema_name
from .six import long, is_str, iterkeys, itervalues
from ._schema_common import SCHEMA_DEFS

MODIFY
fastavro/read.py
fastavro/read.py
@@ -3,23 +3,26 @@ try:
except ImportError as e:
from . import _read_py as _read
-from ._read_common import (
- HEADER_SCHEMA, SYNC_SIZE, MAGIC, SchemaResolutionError
-)
+from . import _read_common
+# Private API
+HEADER_SCHEMA = _read_common.HEADER_SCHEMA
+SYNC_SIZE = _read_common.SYNC_SIZE
+MAGIC = _read_common.MAGIC
acquaint_schema = _read.acquaint_schema
+READERS = _read.READERS
+BLOCK_READERS = _read.BLOCK_READERS
+
+# Public API
reader = iter_avro = _read.reader
block_reader = _read.block_reader
schemaless_reader = _read.schemaless_reader
read_data = _read.read_data
is_avro = _read.is_avro
-
-_READERS = _read.READERS
LOGICAL_READERS = _read.LOGICAL_READERS
-BLOCK_READERS = _read.BLOCK_READERS
+SchemaResolutionError = _read_common.SchemaResolutionError
__all__ = [
- 'acquaint_schema', 'reader', 'schemaless_reader', 'read_data', 'is_avro',
- 'HEADER_SCHEMA', 'SYNC_SIZE', 'MAGIC', 'SchemaResolutionError',
- 'LOGICAL_READERS', 'BLOCK_READERS',
+ 'reader', 'schemaless_reader', 'read_data', 'is_avro', 'block_reader',
+ 'SchemaResolutionError', 'LOGICAL_READERS',
]

MODIFY
fastavro/schema.py
fastavro/schema.py
@@ -5,15 +5,16 @@ except ImportError:
from ._schema_common import UnknownType, SchemaParseException
-_schema_name = _schema.schema_name
-load_schema = _schema.load_schema
+# Private API
+schema_name = _schema.schema_name
extract_record_type = _schema.extract_record_type
-populate_schema_defs = _schema.populate_schema_defs
extract_logical_type = _schema.extract_logical_type
+populate_schema_defs = _schema.populate_schema_defs
extract_named_schemas_into_repo = _schema.extract_named_schemas_into_repo
+# Public API
+load_schema = _schema.load_schema
+
__all__ = [
- 'UnknownType', 'load_schema', 'extract_record_type',
- 'extract_logical_type', 'extract_named_schemas_into_repo',
- 'SchemaParseException',
+ 'UnknownType', 'load_schema', 'SchemaParseException',
]

MODIFY
fastavro/validation.py
fastavro/validation.py
@@ -4,6 +4,7 @@ except ImportError:
from . import _validation_py as _validation
from ._validate_common import ValidationErrorData, ValidationError
+# Public API
validate = _validation.validate
validate_many = _validation.validate_many

MODIFY
fastavro/write.py
fastavro/write.py
@@ -3,18 +3,20 @@ try:
except ImportError as e:
from . import _write_py as _write
+# Private API
SCHEMA_DEFS = _write.SCHEMA_DEFS
acquaint_schema = _write.acquaint_schema
+WRITERS = _write.WRITERS
+
+# Public API
dump = _write.dump
writer = _write.writer
Writer = _write.Writer
schemaless_writer = _write.schemaless_writer
write_data = _write.write_data
-
-_WRITERS = _write.WRITERS
LOGICAL_WRITERS = _write.LOGICAL_WRITERS
__all__ = [
- 'SCHEMA_DEFS', 'acquaint_schema', 'writer', 'schemaless_writer',
- 'write_data', 'LOGICAL_WRITERS',
+ 'dump', 'writer', 'Writer', 'schemaless_writer', 'write_data',
+ 'LOGICAL_WRITERS',
]

MODIFY
tests/conftest.py
tests/conftest.py
@@ -2,23 +2,23 @@ import datetime
import pytest
import time
-from fastavro.read import _READERS
-from fastavro.write import _WRITERS
+from fastavro.read import READERS
+from fastavro.write import WRITERS
from fastavro._schema_common import SCHEMA_DEFS
from fastavro._timezone import utc
@pytest.fixture(scope='function')
def clean_readers_writers_and_schemas():
- reader_keys = {key for key in _READERS.keys()}
- writer_keys = {key for key in _WRITERS.keys()}
+ reader_keys = {key for key in READERS.keys()}
+ writer_keys = {key for key in WRITERS.keys()}
schema_keys = {key for key in SCHEMA_DEFS.keys()}
yield
repo_keys = (
- (_READERS, reader_keys),
- (_WRITERS, writer_keys),
+ (READERS, reader_keys),
+ (WRITERS, writer_keys),
(SCHEMA_DEFS, schema_keys),
)
for repo, keys in repo_keys:

MODIFY
tests/test_fastavro.py
tests/test_fastavro.py
@@ -229,10 +229,10 @@ def test_acquaint_schema_accepts_nested_records_from_arrays():
def test_compose_schemas():
schema_path = join(data_dir, 'Parent.avsc')
fastavro.schema.load_schema(schema_path)
- assert 'Parent' in fastavro.read._READERS
- assert 'Child' in fastavro.read._READERS
- assert 'Parent' in fastavro.write._WRITERS
- assert 'Child' in fastavro.write._WRITERS
+ assert 'Parent' in fastavro.read.READERS
+ assert 'Child' in fastavro.read.READERS
+ assert 'Parent' in fastavro.write.WRITERS
+ assert 'Child' in fastavro.write.WRITERS
def test_reading_after_writing_with_load_schema():
@@ -247,7 +247,7 @@ def test_reading_after_writing_with_load_schema():
# Clean the Child and Parent entries so we are forced to get them from the
# schema
- for repo in (SCHEMA_DEFS, fastavro.write._WRITERS, fastavro.read._READERS):
+ for repo in (SCHEMA_DEFS, fastavro.write.WRITERS, fastavro.read.READERS):
del repo['Child']
del repo['Parent']

make it more clear which are public and private APIs