From 468baa80a7bb3e6af684e7c6b0e1f3327dcf2c8b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 17 Jan 2023 22:06:19 +0000 Subject: [PATCH 1/2] Update flake8-bugbear requirement from <22.13 to <23.2 Updates the requirements on [flake8-bugbear](https://github.com/PyCQA/flake8-bugbear) to permit the latest version. - [Release notes](https://github.com/PyCQA/flake8-bugbear/releases) - [Commits](https://github.com/PyCQA/flake8-bugbear/compare/16.4.1...23.1.14) --- updated-dependencies: - dependency-name: flake8-bugbear dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- dev-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 18beb9a1..379c28a1 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,7 +1,7 @@ diff_cover < 7.5 pylint < 2.16 pydocstyle < 6.4 -flake8-bugbear < 22.13 +flake8-bugbear < 23.2 tox < 3.29 # until tox-pyenv is updated for tox 4.x tox-pyenv < 1.2 isort < 5.12 From 74aa7aeb0d1a849606bbe201ab0c19df1846adb4 Mon Sep 17 00:00:00 2001 From: "Michael R. Crusoe" Date: Wed, 25 Jan 2023 12:11:44 +0100 Subject: [PATCH 2/2] flake8 cleanups --- .flake8 | 9 +++-- Makefile | 7 +++- dev-requirements.txt | 1 + schema_salad/__init__.py | 2 +- schema_salad/avro/schema.py | 5 +-- schema_salad/codegen.py | 2 +- schema_salad/cpp_codegen.py | 20 ++++------ schema_salad/exceptions.py | 18 ++++----- schema_salad/makedoc.py | 38 +++++++++---------- schema_salad/metaschema.py | 6 +-- schema_salad/python_codegen.py | 3 +- schema_salad/python_codegen_support.py | 6 +-- schema_salad/ref_resolver.py | 1 - schema_salad/schema.py | 2 +- schema_salad/tests/test_cli_args.py | 4 +- schema_salad/tests/test_cpp_codegen.py | 4 -- schema_salad/tests/test_errors.py | 39 +++++++++++++------- schema_salad/tests/test_examples.py | 2 +- schema_salad/tests/test_makedoc.py | 10 ++--- schema_salad/tests/test_real_cwl.py | 10 ++--- schema_salad/tests/test_schemas_directive.py | 10 ++--- schema_salad/tests/util.py | 4 +- schema_salad/utils.py | 6 +-- schema_salad/validate.py | 4 +- setup.cfg | 5 --- 25 files changed, 106 insertions(+), 112 deletions(-) diff --git a/.flake8 b/.flake8 index 926c34e9..45fea320 100644 --- a/.flake8 +++ b/.flake8 @@ -1,7 +1,10 @@ [flake8] -ignore = E203, E266, E501, W503, E211, E731 -max-line-length = 88 -select = B,C,E,F,W,T4,B9 +ignore = E203,W503 +max-line-length = 100 +select = B,C,E,F,W,T4 +extend-ignore = E501,B905 +# when Python 3.10 is the minimum version, re-enable check B905 for zip + strict +extend-select = B9 per-file-ignores = schema_salad/metaschema.py:B950 schema_salad/tests/*.py:B011 diff --git a/Makefile b/Makefile index 132a3687..4a57354c 100644 --- a/Makefile +++ b/Makefile @@ -220,8 +220,11 @@ release: twine upload testenv2/src/${PACKAGE}/dist/* && \ git tag ${VERSION} && git push --tags -flake8: $(PYSOURCES) - flake8 $^ +flake8: FORCE + flake8 $(PYSOURCES) + +schema_salad/metaschema.py: schema_salad/codegen_base.py schema_salad/python_codegen_support.py schema_salad/python_codegen.py schema_salad/metaschema + schema-salad-tool --codegen python schema_salad/metaschema/metaschema.yml > $@ FORCE: diff --git a/dev-requirements.txt b/dev-requirements.txt index 379c28a1..2f66727c 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,6 +1,7 @@ diff_cover < 7.5 pylint < 2.16 pydocstyle < 6.4 +flake8 > 4 flake8-bugbear < 23.2 tox < 3.29 # until tox-pyenv is updated for tox 4.x tox-pyenv < 1.2 diff --git a/schema_salad/__init__.py b/schema_salad/__init__.py index 7dab32ef..bbc1ba65 100644 --- a/schema_salad/__init__.py +++ b/schema_salad/__init__.py @@ -1,4 +1,4 @@ -"""Salad is a schema language for describing JSON or YAML structured linked data documents.""" +"""A schema language for describing JSON or YAML structured linked data documents.""" import logging import sys diff --git a/schema_salad/avro/schema.py b/schema_salad/avro/schema.py index 159078f6..534765e2 100644 --- a/schema_salad/avro/schema.py +++ b/schema_salad/avro/schema.py @@ -605,9 +605,8 @@ def make_avsc_object(json_data: JsonDataType, names: Optional[Names] = None) -> ) if not (doc is None or isinstance(doc, str) or isinstance(doc, list)): raise SchemaParseException( - '"doc" for type {} must be a string, a list of strings, or None: {}'.format( - atype, json_data - ) + f'"doc" for type {atype} must be a string, ' + f"a list of strings, or None: {json_data}" ) if atype == "enum": symbols = json_data.get("symbols") diff --git a/schema_salad/codegen.py b/schema_salad/codegen.py index fddbc7e9..623a28fc 100644 --- a/schema_salad/codegen.py +++ b/schema_salad/codegen.py @@ -43,7 +43,7 @@ def codegen( """Generate classes with loaders for the given Schema Salad description.""" j = schema.extend_and_specialize(i, loader) - gen = None # type: Optional[CodeGenBase] + gen: Optional[CodeGenBase] = None base = schema_metadata.get("$base", schema_metadata.get("id")) # ``urlsplit`` decides whether to return an encoded result based # on the object type. To ensure the code behaves the same for Py diff --git a/schema_salad/cpp_codegen.py b/schema_salad/cpp_codegen.py index 19ef8a62..bbc94d90 100644 --- a/schema_salad/cpp_codegen.py +++ b/schema_salad/cpp_codegen.py @@ -7,23 +7,20 @@ The generated code requires the libyaml-cpp library & headers To see an example of usage, look at schema_salad/tests/codegen/cwl.cpp -which can be combined with the CWL V1.0 schema as shown below: +which can be combined with the CWL V1.0 schema as shown below:: -``` -schema-salad-tool --codegen cpp schema_salad/tests/test_schema/CommonWorkflowLanguage.yml \ - > cwl_v1_0.h + schema-salad-tool --codegen cpp \ + schema_salad/tests/test_schema/CommonWorkflowLanguage.yml \ + > cwl_v1_0.h -g++ --std=c++20 -I. -lyaml-cpp schema_salad/tests/codegen/cwl.cpp -o cwl-v1_0-test -./cwl-v1_0-test + g++ --std=c++20 -I. -lyaml-cpp schema_salad/tests/codegen/cwl.cpp -o cwl-v1_0-test + ./cwl-v1_0-test -# g++ versions older than version 10 may need "--std=c++2a" instead of "--std=c++20" -``` + # g++ versions older than version 10 may need "--std=c++2a" instead of "--std=c++20" """ import re from typing import IO, Any, Dict, List, Optional, Tuple, Union, cast -from schema_salad.utils import aslist - from . import _logger from .codegen_base import CodeGenBase, TypeDef from .exceptions import SchemaException @@ -161,7 +158,6 @@ def writeDefinition( self, target: IO[Any], fullInd: str, ind: str, namespace: str ) -> None: name = safename(self.name) - # target.write(f"{fullInd}std::unique_ptr<{self.typeStr}> {name} = std::make_unique<{self.typeStr}>();\n") typeStr = self.typeStr.replace(namespace + "::", "") target.write(f"{fullInd}heap_object<{typeStr}> {name};\n") @@ -599,8 +595,6 @@ def parseEnum(self, stype: Dict[str, Any]) -> str: return name def parse(self, items: List[Dict[str, Any]]) -> None: - types = {i["name"]: i for i in items} # type: Dict[str, Any] - for stype in items: if "type" in stype and stype["type"] == "documentation": continue diff --git a/schema_salad/exceptions.py b/schema_salad/exceptions.py index 13fb2d15..24defe49 100644 --- a/schema_salad/exceptions.py +++ b/schema_salad/exceptions.py @@ -16,14 +16,14 @@ def __init__( ) -> None: super().__init__(msg) self.message = self.args[0] - self.file = None # type: Optional[str] - self.start = None # type: Optional[Tuple[int, int]] - self.end = None # type: Optional[Tuple[int, int]] + self.file: Optional[str] = None + self.start: Optional[Tuple[int, int]] = None + self.end: Optional[Tuple[int, int]] = None - self.is_warning = False # type: bool + self.is_warning: bool = False # It will be set by its parent - self.bullet = "" # type: str + self.bullet: str = "" def simplify(exc: "SchemaSaladException") -> List["SchemaSaladException"]: return [exc] if len(exc.message) else exc.children @@ -36,7 +36,7 @@ def with_bullet( return exc if children is None: - self.children = [] # type: List["SchemaSaladException"] + self.children: List["SchemaSaladException"] = [] elif len(children) <= 1: self.children = sum((simplify(c) for c in children), []) else: @@ -82,10 +82,10 @@ def leaves(self) -> List["SchemaSaladException"]: return [] def prefix(self) -> str: - pre = "" # type:str + pre: str = "" if self.file: - linecol0 = "" # type: Union[int, str] - linecol1 = "" # type: Union[int, str] + linecol0: Union[int, str] = "" + linecol1: Union[int, str] = "" if self.start: linecol0, linecol1 = self.start pre = f"{self.file}:{linecol0}:{linecol1}: " diff --git a/schema_salad/makedoc.py b/schema_salad/makedoc.py index 06d081c5..b81e0c5e 100644 --- a/schema_salad/makedoc.py +++ b/schema_salad/makedoc.py @@ -45,7 +45,7 @@ def vocab_type_name(url: str) -> str: def has_types(items: Any) -> List[str]: - r = [] # type: List[str] + r: List[str] = [] if isinstance(items, MutableMapping): if items["type"] == "https://w3id.org/cwl/salad#record": return [items["name"]] @@ -106,8 +106,9 @@ def block_code(self, code: str, info: Optional[str] = None) -> str: return text + ">" + html.escape(code, quote=self._escape) + "\n" -def markdown_list_hook(markdown, text, state): - # type: (Markdown[str, Any], str, State) -> Tuple[str, State] +def markdown_list_hook( + markdown: "Markdown[str, Any]", text: str, state: "State" +) -> Tuple[str, "State"]: """Patches problematic Markdown lists for later HTML generation. When a Markdown list with paragraphs not indented with the list @@ -286,7 +287,8 @@ def __init__(self) -> None: self.toc = "" self.start_numbering = True - def add_entry(self, thisdepth, title): # type: (int, str) -> str + def add_entry(self, thisdepth: int, title: str) -> str: + """Add an entry to the table of contents.""" depth = len(self.numbering) if thisdepth < depth: self.toc += "" @@ -390,12 +392,12 @@ def __init__( ) -> None: self.typedoc = StringIO() self.toc = toc - self.subs = {} # type: Dict[str, str] - self.docParent = {} # type: Dict[str, List[str]] - self.docAfter = {} # type: Dict[str, List[str]] - self.rendered = set() # type: Set[str] + self.subs: Dict[str, str] = {} + self.docParent: Dict[str, List[str]] = {} + self.docAfter: Dict[str, List[str]] = {} + self.rendered: Set[str] = set() self.redirects = redirects - self.title = None # type: Optional[str] + self.title: Optional[str] = None self.primitiveType = primitiveType for t in j: @@ -418,17 +420,15 @@ def __init__( metaschema_loader = get_metaschema()[2] alltypes = extend_and_specialize(j, metaschema_loader) - self.typemap = {} # type: Dict[str, Dict[str, str]] - self.uses = {} # type: Dict[str, List[Tuple[str, str]]] - self.record_refs = {} # type: Dict[str, List[str]] + self.typemap: Dict[str, Dict[str, str]] = {} + self.uses: Dict[str, List[Tuple[str, str]]] = {} + self.record_refs: Dict[str, List[str]] = {} for entry in alltypes: self.typemap[entry["name"]] = entry try: if entry["type"] == "record": self.record_refs[entry["name"]] = [] - fields = entry.get( - "fields", [] - ) # type: Union[str, List[Dict[str, str]]] + fields: Union[str, List[Dict[str, str]]] = entry.get("fields", []) if isinstance(fields, str): raise KeyError("record fields must be a list of mappings") for f in fields: # type: Dict[str, str] @@ -615,20 +615,20 @@ def extendsfrom(item: Dict[str, Any], ex: List[Dict[str, Any]]) -> None: f["doc"] = number_headings(self.toc, f["doc"]) doc = doc + "\n\n" + f["doc"] - plugins = [ + plugins: List["PluginName"] = [ "strikethrough", "footnotes", "table", "url", - ] # type: List[PluginName] # fix error Generic str != explicit Literals + ] # if escape active, wraps literal HTML into '

{HTML}

' # we must pass it to both since 'MyRenderer' is predefined escape = False - markdown2html = create_markdown( + markdown2html: "Markdown[str, Any]" = create_markdown( renderer=MyRenderer(escape=escape), plugins=plugins, escape=escape, - ) # type: Markdown[str, Any] + ) markdown2html.before_parse_hooks.append(markdown_list_hook) doc = markdown2html(doc) diff --git a/schema_salad/metaschema.py b/schema_salad/metaschema.py index e8b6e4eb..ac9f1dbb 100644 --- a/schema_salad/metaschema.py +++ b/schema_salad/metaschema.py @@ -429,8 +429,7 @@ def __repr__(self): # type: () -> str class _EnumLoader(_Loader): - def __init__(self, symbols, name): - # type: (Sequence[str], str) -> None + def __init__(self, symbols: Sequence[str], name: str) -> None: self.symbols = symbols self.name = name @@ -547,8 +546,7 @@ def load(self, doc, baseuri, loadingOptions, docRoot=None): class _UnionLoader(_Loader): - def __init__(self, alternates): - # type: (Sequence[_Loader]) -> None + def __init__(self, alternates: Sequence[_Loader]) -> None: self.alternates = alternates def load(self, doc, baseuri, loadingOptions, docRoot=None): diff --git a/schema_salad/python_codegen.py b/schema_salad/python_codegen.py index 36f87728..885ff055 100644 --- a/schema_salad/python_codegen.py +++ b/schema_salad/python_codegen.py @@ -377,7 +377,8 @@ def end_class(self, classname: str, field_names: List[str]) -> None: ) if self.idfield: self.out.write( - f" loadingOptions.idx[{self.safe_name(self.idfield)}] = (_constructed, loadingOptions)\n" + f" loadingOptions.idx[{self.safe_name(self.idfield)}] " + "= (_constructed, loadingOptions)\n" ) self.out.write(" return _constructed\n") diff --git a/schema_salad/python_codegen_support.py b/schema_salad/python_codegen_support.py index d8d348cd..0eda7f49 100644 --- a/schema_salad/python_codegen_support.py +++ b/schema_salad/python_codegen_support.py @@ -426,8 +426,7 @@ def __repr__(self): # type: () -> str class _EnumLoader(_Loader): - def __init__(self, symbols, name): - # type: (Sequence[str], str) -> None + def __init__(self, symbols: Sequence[str], name: str) -> None: self.symbols = symbols self.name = name @@ -544,8 +543,7 @@ def load(self, doc, baseuri, loadingOptions, docRoot=None): class _UnionLoader(_Loader): - def __init__(self, alternates): - # type: (Sequence[_Loader]) -> None + def __init__(self, alternates: Sequence[_Loader]) -> None: self.alternates = alternates def load(self, doc, baseuri, loadingOptions, docRoot=None): diff --git a/schema_salad/ref_resolver.py b/schema_salad/ref_resolver.py index 204f98c1..b9cf33eb 100644 --- a/schema_salad/ref_resolver.py +++ b/schema_salad/ref_resolver.py @@ -310,7 +310,6 @@ def add_schemas(self, ns: Union[List[str], str], base_url: str) -> None: break except (xml.sax.SAXParseException, TypeError, BadSyntax) as e: err_msg = str(e) - pass else: _logger.warning( "Could not load extension schema %s: %s", fetchurl, err_msg diff --git a/schema_salad/schema.py b/schema_salad/schema.py index dee3363d..a75cb0aa 100644 --- a/schema_salad/schema.py +++ b/schema_salad/schema.py @@ -369,7 +369,7 @@ def validate_doc( break if not success: - errors = [] # type: List[SchemaSaladException] + errors: List[SchemaSaladException] = [] for root in roots: if hasattr(root, "get_prop"): name = root.get_prop("name") diff --git a/schema_salad/tests/test_cli_args.py b/schema_salad/tests/test_cli_args.py index 67a959b6..e0a181dd 100644 --- a/schema_salad/tests/test_cli_args.py +++ b/schema_salad/tests/test_cli_args.py @@ -20,7 +20,7 @@ def captured_output() -> Iterator[Tuple[StringIO, StringIO]]: def test_version() -> None: - args = [["--version"], ["-v"]] # type: List[List[str]] + args: List[List[str]] = [["--version"], ["-v"]] for arg in args: with captured_output() as (out, err): cli_parser.main(arg) @@ -31,7 +31,7 @@ def test_version() -> None: def test_empty_input() -> None: # running schema_salad tool without any args - args = [] # type: List[str] + args: List[str] = [] with captured_output() as (out, err): cli_parser.main(args) diff --git a/schema_salad/tests/test_cpp_codegen.py b/schema_salad/tests/test_cpp_codegen.py index ac82eb7d..923564c5 100644 --- a/schema_salad/tests/test_cpp_codegen.py +++ b/schema_salad/tests/test_cpp_codegen.py @@ -1,15 +1,12 @@ """Test C++ code generation.""" import os -import subprocess from pathlib import Path from typing import Any, Dict, List, cast from schema_salad import codegen from schema_salad.avro.schema import Names from schema_salad.schema import load_schema -from schema_salad.sourceline import cmap -from schema_salad.utils import yaml_no_ts from .util import cwl_file_uri, get_data @@ -17,7 +14,6 @@ def test_cwl_cpp_gen(tmp_path: Path) -> None: """End to end test of C++ generator using the CWL v1.0 schema.""" src_target = tmp_path / "cwl_v1_0.h" - exe_target = tmp_path / "cwl_v1_0_test" cpp_codegen(cwl_file_uri, src_target) source = get_data("tests/codegen/cwl.cpp") assert source diff --git a/schema_salad/tests/test_errors.py b/schema_salad/tests/test_errors.py index b9c60ffe..a86fcd1f 100644 --- a/schema_salad/tests/test_errors.py +++ b/schema_salad/tests/test_errors.py @@ -12,7 +12,6 @@ from schema_salad.sourceline import cmap from .util import get_data -from .test_cli_args import captured_output def test_errors() -> None: @@ -77,10 +76,13 @@ def test_error_message2() -> None: assert isinstance(avsc_names, Names) t = "test_schema/test2.cwl" - match = r""" -^.+test2\.cwl:2:1: Field `class`\s+contains\s+undefined\s+reference\s+to\s+`file://.+/schema_salad/tests/test_schema/xWorkflow`$"""[ - 1: - ] + match = ( + r""" +^.+test2\.cwl:2:1: Field """ + r"""`class`\s+contains\s+undefined\s+reference\s+to\s+`file://.+/schema_salad/tests/test_schema/xWorkflow`$"""[ + 1: + ] + ) path2 = get_data("tests/" + t) assert path2 with pytest.raises(ValidationException, match=match): @@ -179,12 +181,15 @@ def test_error_message8() -> None: assert isinstance(avsc_names, Names) t = "test_schema/test8.cwl" - match = r""" + match = ( + r""" ^.+test8\.cwl:7:1: checking field\s+`steps` .+test8\.cwl:8:3: checking object\s+`.+test8\.cwl#step1` -.+test8\.cwl:9:5: Field\s+`scatterMethod`\s+contains\s+undefined\s+reference\s+to\s+`file:///.+/tests/test_schema/abc`$"""[ - 1: - ] +.+test8\.cwl:9:5: """ + r"""Field\s+`scatterMethod`\s+contains\s+undefined\s+reference\s+to\s+`file:///.+/tests/test_schema/abc`$"""[ + 1: + ] + ) with pytest.raises(ValidationException, match=match): load_and_validate( document_loader, avsc_names, str(get_data("tests/" + t)), True @@ -241,12 +246,15 @@ def test_error_message11() -> None: assert isinstance(avsc_names, Names) t = "test_schema/test11.cwl" - match = r""" + match = ( + r""" ^.+test11\.cwl:7:1: checking field\s+`steps` .+test11\.cwl:8:3: checking object\s+`.+test11\.cwl#step1` -.+test11\.cwl:9:5: Field `run`\s+contains\s+undefined\s+reference\s+to\s+`file://.+/tests/test_schema/blub\.cwl`$"""[ - 1: - ] +.+test11\.cwl:9:5: """ + r"""Field `run`\s+contains\s+undefined\s+reference\s+to\s+`file://.+/tests/test_schema/blub\.cwl`$"""[ + 1: + ] + ) with pytest.raises(ValidationException, match=match): load_and_validate( document_loader, avsc_names, str(get_data("tests/" + t)), True @@ -365,7 +373,10 @@ def test_namespaces_undeclared(caplog: pytest.LogCaptureFixture) -> None: ) ) - match = r""".*URI prefix 'namesp' of 'namesp:ExampleType' not recognized, are you missing a \$namespaces section?.*""" + match = ( + r""".*URI prefix 'namesp' of 'namesp:ExampleType' not recognized, """ + r"""are you missing a \$namespaces section?.*""" + ) assert re.match(match, caplog.text) diff --git a/schema_salad/tests/test_examples.py b/schema_salad/tests/test_examples.py index f344f227..3f25ab21 100644 --- a/schema_salad/tests/test_examples.py +++ b/schema_salad/tests/test_examples.py @@ -524,7 +524,7 @@ class TestExp(Exception): except TestExp as e: assert str(e).endswith("frag.yml:3:3: Whoops"), e except Exception as exc: - raise AssertionError("Unexpected exception" + str(exc)) + raise AssertionError("Unexpected exception" + str(exc)) from exc def test_cmap() -> None: diff --git a/schema_salad/tests/test_makedoc.py b/schema_salad/tests/test_makedoc.py index a62a8b2b..038b2dbe 100644 --- a/schema_salad/tests/test_makedoc.py +++ b/schema_salad/tests/test_makedoc.py @@ -63,12 +63,12 @@ def fixture_metaschema_doc() -> str: def test_doc_fenced_code_contents_preserved() -> None: """ - Validates that fenced code contents are not interpreted as Markdown definitions and converted into erroneous HTML. + Fenced code contents are not interpreted as Markdown definitions and converted into erroneous HTML. - An example of problem case is when a definition looks like a Markdown list (e.g.: a YAML array). - It must not be converted into HTML contents with list tags. - However, special characters (e.g.: ``<``, ``>``) must still be escaped, otherwise they will not be correctly - rendered within an HTML ``
`` block.
+    An example of problem case is when a definition looks like a Markdown list
+    (e.g.: a YAML array). It must not be converted into HTML contents with list tags.
+    However, special characters (e.g.: ``<``, ``>``) must still be escaped,
+    otherwise they will not be correctly rendered within an HTML ``
`` block.
     """
     data = inspect.cleandoc(
         """
diff --git a/schema_salad/tests/test_real_cwl.py b/schema_salad/tests/test_real_cwl.py
index 41918172..b3e3c519 100644
--- a/schema_salad/tests/test_real_cwl.py
+++ b/schema_salad/tests/test_real_cwl.py
@@ -4,7 +4,7 @@
 run individually as py.test -k tests/test_real_cwl.py
 """
 
-from typing import Any, Dict, Union
+from typing import Any, Dict, Optional, Union
 
 import pytest
 
@@ -19,10 +19,10 @@
 
 
 class TestRealWorldCWL:
-    document_loader = None  # type: Loader
-    avsc_names = None  # type: Union[Names, SchemaParseException]
-    schema_metadata = None  # type: Dict[str, Any]
-    metaschema_loader = None  # type: Loader
+    document_loader: Loader
+    avsc_names: Union[Names, SchemaParseException, None] = None
+    schema_metadata: Optional[Dict[str, Any]] = None
+    metaschema_loader: Optional[Loader] = None
 
     @classmethod
     def setup_class(cls) -> None:
diff --git a/schema_salad/tests/test_schemas_directive.py b/schema_salad/tests/test_schemas_directive.py
index 1fae2c45..7c2fc979 100644
--- a/schema_salad/tests/test_schemas_directive.py
+++ b/schema_salad/tests/test_schemas_directive.py
@@ -5,7 +5,7 @@
 """
 
 import os
-from typing import Any, Dict, Tuple, Union
+from typing import Any, Dict, Optional, Tuple, Union
 
 from schema_salad.avro.schema import Names, SchemaParseException
 from schema_salad.ref_resolver import Loader
@@ -19,10 +19,10 @@
 class TestSchemasDirective:
     """Ensure codegen-produced parsers accept $schemas directives"""
 
-    document_loader = None  # type: Loader
-    avsc_names = None  # type: Union[Names, SchemaParseException]
-    schema_metadata = None  # type: Dict[str, Any]
-    metaschema_loader = None  # type: Loader
+    document_loader: Loader
+    avsc_names: Union[Names, SchemaParseException, None] = None
+    schema_metadata: Optional[Dict[str, Any]] = None
+    metaschema_loader: Optional[Loader] = None
 
     @classmethod
     def setup_class(cls) -> None:
diff --git a/schema_salad/tests/util.py b/schema_salad/tests/util.py
index d90ad422..3b3ace90 100644
--- a/schema_salad/tests/util.py
+++ b/schema_salad/tests/util.py
@@ -1,12 +1,12 @@
 import os
-from typing import Optional, Text
+from typing import Optional
 
 from pkg_resources import Requirement, ResolutionError, resource_filename
 
 from schema_salad import ref_resolver
 
 
-def get_data(filename):  # type: (Text) -> Optional[Text]
+def get_data(filename: str) -> Optional[str]:
     """Get the file path for a given schema file name.
 
     It is able to find file names in the ``schema_salad`` namespace, but
diff --git a/schema_salad/utils.py b/schema_salad/utils.py
index 0309fe32..7097c0f7 100644
--- a/schema_salad/utils.py
+++ b/schema_salad/utils.py
@@ -96,11 +96,7 @@ def convert_to_dict(j4):  # type: (Any) -> Any
         return j4
 
 
-def json_dump(
-    obj,  # type: Any
-    fp,  # type: IO[str]
-    **kwargs  # type: Any
-):  # type: (...) -> None
+def json_dump(obj: Any, fp: IO[str], **kwargs: Any) -> None:
     """Force use of unicode."""
     json.dump(convert_to_dict(obj), fp, **kwargs)
 
diff --git a/schema_salad/validate.py b/schema_salad/validate.py
index 266d8732..e133e8cb 100644
--- a/schema_salad/validate.py
+++ b/schema_salad/validate.py
@@ -4,7 +4,7 @@
 from urllib.parse import urlsplit
 
 from . import avro
-from .avro.schema import Schema  # pylint: disable=no-name-in-module, import-error
+from .avro.schema import Schema
 from .exceptions import (
     ClassValidationException,
     SchemaSaladException,
@@ -260,7 +260,7 @@ def validate_ex(
         if not raise_ex:
             return False
 
-        errors = []  # type: List[SchemaSaladException]
+        errors: List[SchemaSaladException] = []
         checked = []
         for s in expected_schema.schemas:
             if isinstance(datum, MutableSequence) and not isinstance(
diff --git a/setup.cfg b/setup.cfg
index aae8e39d..cf9fe0a2 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,8 +1,3 @@
-[flake8]
-ignore = E124,E128,E129,E201,E202,E225,E226,E231,E265,E271,E302,E303,F401,E402,E501,W503,E731,F811,F821,F841
-max-line-length = 88
-extend-ignore = E203, W503
-
 [aliases]
 test=pytest