Skip to content

Commit

Permalink
modernize type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
joamatab committed Aug 6, 2023
1 parent 164818a commit 471093e
Show file tree
Hide file tree
Showing 35 changed files with 176 additions and 215 deletions.
4 changes: 2 additions & 2 deletions .github/write_components_autodoc.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import inspect

import ubcpdk
from ubcpdk.config import PATH


filepath = PATH.repo / "docs" / "components.rst"

skip = {
Expand Down Expand Up @@ -51,7 +51,7 @@
[
f"{p}={repr(sig.parameters[p].default)}"
for p in sig.parameters
if isinstance(sig.parameters[p].default, (int, float, str, tuple))
if isinstance(sig.parameters[p].default, int | float | str | tuple)
and p not in skip_settings
]
)
Expand Down
11 changes: 5 additions & 6 deletions .github/write_components_plot.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from typing import Tuple
import inspect
from ubcpdk.config import PATH
from ubcpdk import cells

from ubcpdk import cells
from ubcpdk.config import PATH

filepath = PATH.repo / "docs" / "components_plot.rst"

Expand All @@ -20,8 +19,8 @@
"waveguide_template",
}

skip_plot: Tuple[str, ...] = ("add_fiber_array_siepic",)
skip_settings: Tuple[str, ...] = ("flatten", "safe_cell_names")
skip_plot: tuple[str, ...] = ("add_fiber_array_siepic",)
skip_settings: tuple[str, ...] = ("flatten", "safe_cell_names")


with open(filepath, "w+") as f:
Expand All @@ -45,7 +44,7 @@
[
f"{p}={repr(sig.parameters[p].default)}"
for p in sig.parameters
if isinstance(sig.parameters[p].default, (int, float, str, tuple))
if isinstance(sig.parameters[p].default, int | float | str | tuple)
and p not in skip_settings
]
)
Expand Down
11 changes: 5 additions & 6 deletions .github/write_components_plot_klayout.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from typing import Tuple
import inspect
from ubcpdk.config import PATH
from ubcpdk import cells

from ubcpdk import cells
from ubcpdk.config import PATH

filepath = PATH.repo / "docs" / "components_plot.rst"

Expand All @@ -20,8 +19,8 @@
"waveguide_template",
}

skip_plot: Tuple[str, ...] = ("add_fiber_array_siepic",)
skip_settings: Tuple[str, ...] = ("flatten", "safe_cell_names")
skip_plot: tuple[str, ...] = ("add_fiber_array_siepic",)
skip_settings: tuple[str, ...] = ("flatten", "safe_cell_names")


with open(filepath, "w+") as f:
Expand All @@ -45,7 +44,7 @@
[
f"{p}={repr(sig.parameters[p].default)}"
for p in sig.parameters
if isinstance(sig.parameters[p].default, (int, float, str, tuple))
if isinstance(sig.parameters[p].default, int | float | str | tuple)
and p not in skip_settings
]
)
Expand Down
11 changes: 5 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: requirements-txt-fixer
- repo: https://github.com/pycqa/isort
rev: 7b69d092ae4885dcc45648538ae780a6326bcd1e
hooks:
- id: isort
files: ubcdpk/.*
args: [--profile, black, --filter-files]

- repo: https://github.com/psf/black
rev: 25d886f52c2bbbb58386ac8050f4e67952507bc7
Expand All @@ -23,3 +17,8 @@ repos:
rev: "6a0ba1854991b693612486cc84a2254de82d071d"
hooks:
- id: ruff
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.10.0
hooks:
- id: pretty-format-toml
args: [--autofix]
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Changelog

## [2.0.0](https://github.com/gdsfactory/ubc/pull/204)

- update to gdsfactory 7
## [2.0.0](https://github.com/gdsfactory/ubc/pull/291)

- update to gdsfactory 7.0.2

## [1.21.0](https://github.com/gdsfactory/ubc/pull/203)

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ install:
dev:
pip install -e .[dev,docs]

update:
pre-commit autoupdate --bleeding-edge
update-pre:
pre-commit autoupdate

watch:
gf watch ubcpdk
Expand Down
4 changes: 2 additions & 2 deletions install_tech.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Symlink tech to klayout."""
import sys
import os
import shutil
import pathlib
import shutil
import sys


def remove_path_or_dir(dest: pathlib.Path):
Expand Down
165 changes: 70 additions & 95 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,52 +1,47 @@
# https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html

[build-system]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"
requires = ["flit_core >=3.2,<4"]

[project]
name="ubcpdk"
description="ubcpdk pdk"
authors = [
{name = "gdsfactory", email = "[email protected]"}
]
classifiers = [
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Operating System :: OS Independent",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Operating System :: OS Independent"
]
version="1.21.3"
authors = [
{name = "gdsfactory", email = "[email protected]"},
dependencies = [
"gdsfactory==7.0.2",
"gplugins[tidy3d]>=0.0.3,<0.1.0"
]
description = "ubcpdk pdk"
keywords = ["python"]
license = {file = "LICENSE"}
dependencies = [
"gdsfactory==7.0.2",
"gplugins[tidy3d]>=0.0.3,<0.1.0",
]
name = "ubcpdk"
readme = "README.md"
requires-python = ">=3.10"
version = "1.21.3"

[project.optional-dependencies]
full = [
"femwell"
]
dev = [
"pytest",
"pytest-cov",
"pytest_regressions",
]
"pytest",
"pytest-cov",
"pytest_regressions"
]
docs = [
"autodoc_pydantic",
"jupytext",
"jupyter-book==0.15.1",
]

[tool.setuptools.packages]
find = {}
"jupyter-book==0.15.1"
]
full = [
"femwell"
]

[tool.black]
line-length = 88
target-version = ['py310']
include = '\.pyi?$'
exclude = ''' # Specify the files/dirs that should be ignored by the black formatter
/(
\.eggs
Expand All @@ -62,83 +57,63 @@ exclude = ''' # Specify the files/dirs that should be ignored by the black form
| dist
)/
'''

[tool.pytest.ini_options]
testpaths = ["tests"]
# testpaths = ["ubcpdk/samples", "tests"]
# addopts = --tb=no
# addopts = '--tb=short'
# python_files = ["ubcpdk/samples*.py", "tests/*.py"]
python_files = ["tests/*.py"]
# norecursedirs = ["extra/*.py", 'ubcdpk/simulations/*.py']

[tool.flake8]
max-line-length = 88
max-complexity = 57
select = ["B","C","E","F","W","T4","B9"]
ignore = [ "E501", "E503", "E722", "W503", "W503", "E203", "B950", "B305", "B018", "B902", "B020", "B905"]
extend-ignore = "RST303"

exclude = [
".git",
"__pycache__",
"lib",
"docs/source/conf.py",
"build",
"dist",
".ipynb_checkpoints",
".tox",
"extra",
"deprecated",
".mypy_cache",
"venv",
"devsim",
]

[tool.commitizen]
name = "cz_conventional_commits"
version = "0.1.0"
version_files = [
"pyproject.toml:version",
]
include = '\.pyi?$'
line-length = 88
target-version = ['py310']

[tool.mypy]
python_version = "3.10"
strict = true

[tool.pydocstyle]
add-ignore = ["D100", "D101", "D102", "D103", "D104", "D203", "D405", "D417"]
convention = "google"
inherit = false
match = "(?!test).*\\.py"

[tool.pylsp-mypy]
enabled = true
live_mode = true
strict = true

[tool.isort]
multi_line_output = 3
line_length = 88
include_trailing_comma = true

[tool.setuptools.package-data]
mypkg = ["*.csv", "*.yaml"]

[tool.pydocstyle]
inherit = false
match = "(?!test).*\\.py"
add-ignore = ["D100","D101","D102","D103","D104","D203","D405","D417"]
convention = "google"
[tool.pytest.ini_options]
# testpaths = ["ubcpdk/samples", "tests"]
# addopts = --tb=no
# addopts = '--tb=short'
# python_files = ["ubcpdk/samples*.py", "tests/*.py"]
python_files = ["tests/*.py"]
testpaths = ["tests"]

[tool.ruff]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
# "I", # isort
"C", # flake8-comprehensions
"B", # flake8-bugbear
]
extend-exclude = ["docs/notebooks"]
ignore = [
"E501", # line too long, handled by black
"B008", # do not perform function calls in argument defaults
"C901", # too complex
"B905", # `zip()` without an explicit `strict=` parameter
"C408", # C408 Unnecessary `dict` call (rewrite as a literal)
"E501", # line too long, handled by black
"B008", # do not perform function calls in argument defaults
"C901", # too complex
"B905", # `zip()` without an explicit `strict=` parameter
"C408" # C408 Unnecessary `dict` call (rewrite as a literal)
]
extend-exclude = ["docs/notebooks"]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"C", # flake8-comprehensions
"B", # flake8-bugbear
"UP"
]

[tool.ruff.per-file-ignores]
"ubcpdk/samples/notebooks/11_sparameters.py" = ['E402']
"ubcpdk/samples/notebooks/12_sim_plugins_tidy3d.py" = ['E402']
"ubcpdk/samples/notebooks/13_sim_plugins.py" = ['E402']
"ubcpdk/samples/notebooks/14_sax_tidy3d.py" = ['E402']
"ubcpdk/samples/notebooks/21_schematic_driven_layout.py" = ['E402']
"ubcpdk/samples/notebooks/31_data_analysis_mzi.py" = ['E402']
"ubcpdk/samples/notebooks/33_data_analysis_dbr.py" = ['E402']

[tool.setuptools.package-data]
mypkg = ["*.csv", "*.yaml"]

[tool.setuptools.packages]
find = {}
6 changes: 3 additions & 3 deletions tests/test_components.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import pathlib
import pytest
from pytest_regressions.data_regression import DataRegressionFixture

import pytest
from gdsfactory.component import Component
from gdsfactory.difftest import difftest
from ubcpdk import cells
from pytest_regressions.data_regression import DataRegressionFixture

from ubcpdk import cells

skip_test = {
"add_siepic_labels",
Expand Down
9 changes: 2 additions & 7 deletions ubcpdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@
from gdsfactory.get_factories import get_cells
from gdsfactory.pdk import Pdk

from ubcpdk import components, data, tech
from ubcpdk.config import CONFIG, PATH, module
from ubcpdk.tech import LAYER, strip, LAYER_STACK, LAYER_VIEWS
from ubcpdk import components
from ubcpdk import tech
from ubcpdk import data

from ubcpdk.tech import cross_sections

from ubcpdk.tech import LAYER, LAYER_STACK, LAYER_VIEWS, cross_sections, strip

__version__ = "1.21.3"

Expand Down
Loading

0 comments on commit 471093e

Please sign in to comment.