Skip to content

Commit

Permalink
Update to Pydantic 2.0; temporarily disable rstcheck.
Browse files Browse the repository at this point in the history
  • Loading branch information
zaneselvans committed Jul 21, 2023
1 parent e05d7c7 commit bb67741
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ requires-python = ">=3.10,<3.12"
dynamic = ["version"]
license = {file = "LICENSE.txt"}
dependencies = [
"pydantic>=1.9,<3",
"pydantic>=2,<3",
"coloredlogs>=14.0,<15.1",
"arelle-release>=2.3,<2.12",
"frictionless>=4.4,<5",
Expand Down Expand Up @@ -84,7 +84,7 @@ tests = [
"pytest>=6.2,<7.5", # Our testing framework
"pytest-console-scripts>=1.1,<1.5", # Allow automatic testing of scripts
"pytest-cov>=2.10,<4.2", # Pytest plugin for working with coverage
"rstcheck[sphinx]>=5.0,<6.2", # ReStructuredText linter
#"rstcheck[sphinx]>=5.0,<6.2", # ReStructuredText linter
"tox>=4.0,<4.7", # Python test environment manager
]
types = [
Expand Down
2 changes: 1 addition & 1 deletion src/ferc_xbrl_extractor/arelle_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class Metadata(BaseModel):
name: str
references: References
calculations: list[Calculation]
balance: Literal["credit", "debit"] | None
balance: Literal["credit", "debit"] | None = None

@classmethod
def from_concept(cls, concept: ModelConcept) -> "Metadata":
Expand Down
9 changes: 5 additions & 4 deletions src/ferc_xbrl_extractor/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import stringcase
from lxml import etree # nosec: B410
from lxml.etree import _Element as Element # nosec: B410
from pydantic import BaseModel, validator
from pydantic import BaseModel, field_validator

XBRL_INSTANCE = "http://www.xbrl.org/2003/instance"

Expand All @@ -20,7 +20,7 @@ class Period(BaseModel):
"""

instant: bool
start_date: str | None
start_date: str | None = None
end_date: str

@classmethod
Expand Down Expand Up @@ -61,7 +61,8 @@ class Axis(BaseModel):
value: str = ""
dimension_type: DimensionType

@validator("name", pre=True) # type: ignore
@field_validator("name", mode="before") # type: ignore
@classmethod
def strip_prefix(cls, name: str): # noqa: N805
"""Strip XML prefix from name."""
return name.split(":")[1] if ":" in name else name
Expand Down Expand Up @@ -192,7 +193,7 @@ class Fact(BaseModel):

name: str
c_id: str
value: str | None
value: str | None = None

@classmethod
def from_xml(cls, elem: Element) -> "Fact":
Expand Down
2 changes: 1 addition & 1 deletion src/ferc_xbrl_extractor/taxonomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class Concept(BaseModel):
type_: XBRLType = pydantic.Field(alias="type")
period_type: Literal["duration", "instant"]
child_concepts: "list[Concept]"
metadata: Metadata | None
metadata: Metadata | None = None

@classmethod
def from_list(cls, concept_list: list, concept_dict: ConceptDict) -> "Concept":
Expand Down
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ skip_install = false
extras =
{[testenv:pre_commit]extras}
{[testenv:bandit]extras}
{[testenv:rstcheck]extras}
# {[testenv:rstcheck]extras}
{[testenv:flake8]extras}
commands =
{[testenv:pre_commit]commands}
{[testenv:bandit]commands}
{[testenv:rstcheck]commands}
# {[testenv:rstcheck]commands}
{[testenv:flake8]commands}

#######################################################################################
Expand All @@ -91,11 +91,11 @@ description = Build the HTML docs from scratch using Sphinx.
skip_install = false
extras =
{[testenv:doc8]extras}
{[testenv:rstcheck]extras}
# {[testenv:rstcheck]extras}
commands =
bash -c 'rm -rf docs/_build'
{[testenv:doc8]commands}
{[testenv:rstcheck]commands}
# {[testenv:rstcheck]commands}
sphinx-build -W -b html docs docs/_build/html

#######################################################################################
Expand Down

0 comments on commit bb67741

Please sign in to comment.