Skip to content

Commit

Permalink
Fix uv run autodesk
Browse files Browse the repository at this point in the history
Use project structure with src/ directory and main() in __init__.py.
  • Loading branch information
daoo committed Oct 22, 2024
1 parent d79ec12 commit c592dc9
Show file tree
Hide file tree
Showing 29 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ jobs:
- name: Install the project
run: uv sync --all-extras --dev
- name: Run ruff check
run: uv run ruff check bin autodesk tests
run: uv run ruff check bin src tests
- name: Run tests
run: uv run pytest --cov=autodesk --cov-branch --cov-report=term --cov-report=json tests
run: uv run pytest --cov=src --cov-branch --cov-report=term --cov-report=json tests
- name: Run coverage JSON report
run: uv run coverage json
- name: Upload to codecov
Expand Down
Empty file removed autodesk/__init__.py
Empty file.
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ requires-python = ">=3.12"
[project.urls]
homepage = "https://github.com/daoo/autodesk"

[project.scripts]
autodesk = "autodesk:main"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.uv]
dev-dependencies = [
"mock>=5.1.0",
Expand Down
3 changes: 0 additions & 3 deletions autodesk/__main__.py → src/autodesk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,3 @@ def main():
)
app = setup_app(button_pin, factory)
web.run_app(app, host=address, port=port)


main()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ def _connect(self):
if self.controller is not None:
# Finicky way to get pyftdi to clean up and reconnect properly
# after a hardware disconnect. Not necessary on first connect.
assert self.controller._ftdi._usb_dev is not None
UsbTools.release_device(self.controller._ftdi._usb_dev)
UsbTools.release_device(self.controller._ftdi._usb_dev) # type: ignore
self.controller.close()
UsbTools.flush_cache()
else:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 4 additions & 1 deletion tests/integration/test_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@

@pytest.fixture
def process():
cmd = ["python3", "-u", "-m", "autodesk"]
cmd = ["autodesk"]
env = os.environ.copy()
env["PYTHONUNBUFFERED"] = "x"
env["AUTODESK_ADDRESS"] = "127.0.0.1"
env["AUTODESK_CONFIG"] = "config/testing.yml"
env["AUTODESK_DATABASE"] = ":memory:"
env["AUTODESK_PORT"] = "8081"
process = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8", env=env
)
assert process.stdout
assert process.stderr

assert process.stdout is not None
assert process.stderr is not None
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_hardware_ft232h.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ def assign_direction(_, direction):


@pytest.fixture
def factory(controller_fake, gpio_fake):
def factory():
factory_instance = Ft232hPinFactory()
yield factory_instance
factory_instance.close()


def test_factory_constructor(controller_fake):
def test_factory_constructor():
factory = Ft232hPinFactory()
factory.close()

Expand Down Expand Up @@ -186,7 +186,7 @@ def test_pin_read_two_failures_raises(mocker, gpio_fake, factory):


def test_pin_write_failure_recovery(mocker, gpio_fake, factory):
def fail_once(value):
def fail_once(_):
gpio_fake.write.side_effect = None
raise FtdiError("Stubbed error for unit testing.")

Expand Down

0 comments on commit c592dc9

Please sign in to comment.