Skip to content

Commit

Permalink
Remove write cli option
Browse files Browse the repository at this point in the history
  • Loading branch information
remisalmon committed Jul 24, 2024
1 parent d1b922d commit fafcb92
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 24 deletions.
10 changes: 3 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ Once your local repository is set up, develop away on your feature! Double-check

## Test suite and continuous integration

To run the full test suite locally, you'll need to install Docker. Once Docker is installed, the following command will run the test suite:
To run the full test suite locally, you'll need to install tox. Once tox is installed, the following command will run the test suite:

```
docker compose --rm test
tox
```

The test suite for `lkml` is defined in `scripts/run_tests.sh` for local testing and `.circleci/config.yml` for CI builds. The test suite runs the following:
The test suite for `lkml` is defined in `tox.ini` for local testing and `.circleci/config.yml` for CI builds. The test suite runs the following:

* [`pytest`](https://docs.pytest.org/en/latest/) to run unit and functional Python tests
* [`mypy`](http://mypy-lang.org/) to check types
Expand All @@ -31,10 +31,6 @@ The test suite for `lkml` is defined in `scripts/run_tests.sh` for local testing
* [`black`](https://black.readthedocs.io/en/stable/) to auto-format Python code
* [`isort`](https://isort.readthedocs.io/en/latest/) to check for import statement order

### Local testing vs. CI builds

When run locally, `black` and `isort` will automatically format code. When run as part of a CI build, they only check for proper formatting and will fail the build if the formatting is incorrect.

### Testing against public LookML from GitHub

`lkml` contains some helpful scripts to download public LookML from GitHub and run the parser and serializer against the downloaded files. This is an excellent way to test your changes against a large variety of LookML.
Expand Down
13 changes: 1 addition & 12 deletions lkml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,6 @@ def parse_args(args: Sequence) -> argparse.Namespace:
default=False,
help="return a LookML string",
)
group.add_argument(
"-w",
"--write",
action="store_true",
default=False,
help="parse and write back to file",
)

return parser.parse_args(args)

Expand All @@ -140,11 +133,7 @@ def cli():
try:
result: dict = load(args.file)

if args.write:
args.file.seek(0)
dump(result, args.file)
args.file.truncate()
elif args.lookml:
if args.lookml:
lookml_string = dump(result)
print(lookml_string)
elif args.json:
Expand Down
8 changes: 3 additions & 5 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,16 @@ def test_load_with_bad_argument_raises_type_error():
def test_parse_default_option(lookml_path):
args = lkml.parse_args([lookml_path])
assert args.json is True
assert args.lookml is args.write is False
assert args.lookml is False


def test_parse_options(lookml_path):
args = lkml.parse_args([lookml_path, "--json"])
assert args.json is True

args = lkml.parse_args([lookml_path, "--lookml"])
assert args.lookml is True
args = lkml.parse_args([lookml_path, "--write"])
assert args.write is True
args = lkml.parse_args([lookml_path, "-w"])
assert args.write is True

with pytest.raises(SystemExit):
args = lkml.parse_args([lookml_path, "--json", "--lookml"])

Expand Down

0 comments on commit fafcb92

Please sign in to comment.