-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #158 from jdkandersson/bug/constructable-xtablenam…
…e-malformed Bug/constructable xtablename malformed
- Loading branch information
Showing
11 changed files
with
89 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
"""Facades for ringfenced modules.""" | ||
# pylint: disable=useless-import-alias | ||
|
||
from . import code_formatter as code_formatter | ||
from . import jsonschema as jsonschema | ||
from . import models as models | ||
from . import sqlalchemy as sqlalchemy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"""Apply automatic code formatting to source code.""" | ||
|
||
import black | ||
|
||
|
||
def apply(*, source: str) -> str: | ||
""" | ||
Apply automatic code formatting to source code. | ||
Args: | ||
source: The source code. | ||
Returns: | ||
The formatted source code. | ||
""" | ||
try: | ||
return black.format_file_contents( | ||
src_contents=source, fast=False, mode=black.FileMode() | ||
) | ||
except black.NothingChanged: | ||
return source |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"""Tests for code formatting.""" | ||
|
||
import pytest | ||
|
||
from open_alchemy import facades | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"source, expected_source", | ||
[ | ||
pytest.param("'test'\n", '"test"\n', id="apply formatting"), | ||
pytest.param('"test"\n', '"test"\n', id="no formatting"), | ||
], | ||
) | ||
@pytest.mark.facade | ||
@pytest.mark.code_formatter | ||
def test_apply(source, expected_source): | ||
""" | ||
GIVEN source code and expected source code | ||
WHEN apply is called with the source code | ||
THEN the expected source code is returned. | ||
""" | ||
returned_source = facades.code_formatter.apply(source=source) | ||
|
||
assert returned_source == expected_source |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters