diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..a7aae82 --- /dev/null +++ b/.flake8 @@ -0,0 +1,2 @@ +[flake8] +select = T201, T203, T204 # T002 is the specific code for print statements in flake8-print diff --git a/.github/workflows/actions.yaml b/.github/workflows/actions.yaml index c2335be..c363cee 100644 --- a/.github/workflows/actions.yaml +++ b/.github/workflows/actions.yaml @@ -21,9 +21,7 @@ jobs: - name: install python packages run: | python -m pip install --upgrade pip - pip install . - pip install pytest - pip install pytest-black + pip install .[dev] - name: execute pytest - run: pytest tests/ + run: pytest surface-sim/ tests/ diff --git a/pyproject.toml b/pyproject.toml index 8997a7e..351574a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,5 +33,4 @@ include = ["surface_sim", "surface_sim.*"] # package names should match these g namespaces = false # to disable scanning PEP 420 namespaces (true by default) [project.optional-dependencies] -dev = ["pip-tools", "pytest", "black", "pytest-black"] - +dev = ["pip-tools", "pytest", "black", "pytest-black", "flake8", "flake8-print", "pytest-flake8"] diff --git a/pytest.ini b/pytest.ini index 728748d..d58274d 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,3 +1,3 @@ [pytest] -addopts = --black --import-mode=importlib +addopts = --black --import-mode=importlib --flake8 --cache-clear python_files = test_*.py diff --git a/requirements_dev.txt b/requirements_dev.txt index 46947d3..7015c6b 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -28,6 +28,13 @@ dill==0.3.8 # via lmfit exceptiongroup==1.2.2 # via pytest +flake8==5.0.4 + # via + # flake8-print + # pytest-flake8 + # surface-sim (pyproject.toml) +flake8-print==5.0.0 + # via surface-sim (pyproject.toml) fonttools==4.53.1 # via matplotlib galois==0.0.16 @@ -42,6 +49,8 @@ lmfit==1.3.2 # via qec-util matplotlib==3.9.2 # via qec-util +mccabe==0.7.0 + # via flake8 mypy-extensions==1.0.0 # via black netcdf4==1.7.1.post2 @@ -84,6 +93,12 @@ platformdirs==4.2.2 # via black pluggy==1.5.0 # via pytest +pycodestyle==2.9.1 + # via + # flake8 + # flake8-print +pyflakes==2.5.0 + # via flake8 pyparsing==3.1.2 # via matplotlib pyproject-hooks==1.1.0 @@ -93,9 +108,12 @@ pyproject-hooks==1.1.0 pytest==8.3.2 # via # pytest-black + # pytest-flake8 # surface-sim (pyproject.toml) pytest-black==0.3.12 # via surface-sim (pyproject.toml) +pytest-flake8==1.2.2 + # via surface-sim (pyproject.toml) python-dateutil==2.9.0.post0 # via # matplotlib diff --git a/surface_sim/layouts/operations.py b/surface_sim/layouts/operations.py index 28ba7a3..35aa604 100644 --- a/surface_sim/layouts/operations.py +++ b/surface_sim/layouts/operations.py @@ -17,7 +17,6 @@ def check_overlap_layout_pair(layout_1: Layout, layout_2: Layout) -> None: """ qubits_1 = set(layout_1.get_qubits()) qubits_2 = set(layout_2.get_qubits()) - print(qubits_1, qubits_2) if qubits_1.intersection(qubits_2) != set(): raise ValueError("The layouts have qubits with the same label.") diff --git a/tests/log_gates/test_unrot_surface_code_css.py b/tests/log_gates/test_unrot_surface_code_css.py index 294df06..6204fc5 100644 --- a/tests/log_gates/test_unrot_surface_code_css.py +++ b/tests/log_gates/test_unrot_surface_code_css.py @@ -5,7 +5,6 @@ def test_set_trans_s(): layout = unrot_surface_code(distance=3) - print(layout.get_qubits(role="data")) set_trans_s(layout, "D1") gate_label = f"trans_s_{layout.get_logical_qubits()[0]}"