Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused code #87

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ repos:
rev: v3.13.0
hooks:
- id: reorder-python-imports
- repo: https://github.com/jendrikseipp/vulture
rev: 'v2.11'
hooks:
- id: vulture
32 changes: 0 additions & 32 deletions onetimepass/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ class TOTPParams(BaseModel):
time_step_seconds: int


OTPParams = typing.Union[HOTPParams, TOTPParams]


class AliasSchema(BaseModel):
secret: str
digits_count: int
Expand Down Expand Up @@ -116,29 +113,6 @@ def initialize(cls) -> DatabaseSchema:
def add_alias(self, name: str, data: AliasSchema):
self.otp[name] = data

def add_totp_alias(
self,
name: str,
label: str,
issuer: str,
secret: str,
digits_count: int,
hash_algorithm: HashAlgorithm,
initial_time: datetime.datetime,
time_step_seconds: int = settings.DEFAULT_TIME_STEP_SECONDS,
):
self.otp[name] = AliasSchema(
secret=secret,
label=label,
issuer=issuer,
digits_count=digits_count,
hash_algorithm=hash_algorithm,
otp_type=OTPType.TOTP,
params=TOTPParams(
initial_time=initial_time, time_step_seconds=time_step_seconds
),
)

def merge(self, other: DatabaseSchema):
if other.version != self.version:
raise exceptions.DBUnsupportedMigration(
Expand All @@ -154,9 +128,3 @@ def merge(self, other: DatabaseSchema):
)

self.otp |= other.otp


def get_params_by_type(
type_: OTPType,
) -> typing.Type[HOTPParams] | typing.Type[TOTPParams]:
return {OTPType.HOTP: HOTPParams, OTPType.TOTP: TOTPParams}[type_]
1 change: 0 additions & 1 deletion onetimepass/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
SUPPORTED_DB_VERSION = [
DEFAULT_DB_VERSION,
]
DEFAULT_HASH_ALGORITHM = "sha1"
DEFAULT_DIGITS_COUNT = 6
DEFAULT_TIME_STEP_SECONDS = 30
DEFAULT_INITIAL_HOTP_COUNTER = 0
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,9 @@ dev = [
"pre-commit~=2.16",
]

[tool.vulture]
exclude = ["__pypackages__", ".venv"]
paths = ["."]

[project.scripts]
otp = "onetimepass.otp:otp"
35 changes: 35 additions & 0 deletions whitelist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""A whitelist for `vulture` (dead code detector)

Generated via
```
$ vulture --make-whitelist >whitelist.py
```

See:
https://github.com/jendrikseipp/vulture/tree/v2.11?tab=readme-ov-file#whitelists
"""

valid_base32_secret # unused function (onetimepass/db/models.py:80)
valid_params_for_otp_type # unused function (onetimepass/db/models.py:88)
supported_version # unused function (onetimepass/db/models.py:105)
_._missing_ # unused method (onetimepass/enum.py:12)
SHA256 # unused variable (onetimepass/enum.py:27)
SHA512 # unused variable (onetimepass/enum.py:28)
show # unused function (onetimepass/otp.py:146)
init # unused function (onetimepass/otp.py:220)
delete # unused function (onetimepass/otp.py:261)
list_ # unused function (onetimepass/otp.py:281)
export # unused function (onetimepass/otp.py:302)
import_ # unused function (onetimepass/otp.py:316)
add_uri # unused function (onetimepass/otp.py:351)
add_hotp # unused function (onetimepass/otp.py:427)
add_totp # unused function (onetimepass/otp.py:479)
rename # unused function (onetimepass/otp.py:539)
msg_template # unused variable (onetimepass/otpauth/errors.py:10)
msg_template # unused variable (onetimepass/otpauth/errors.py:18)
msg_template # unused variable (onetimepass/otpauth/errors.py:23)
issuer_must_match_pattern # unused function (onetimepass/otpauth/schemas.py:24)
strip_leading_spaces # unused function (onetimepass/otpauth/schemas.py:109)
scheme_must_be_otpauth # unused function (onetimepass/otpauth/schemas.py:125)
set_label # unused function (onetimepass/otpauth/schemas.py:131)
parameters_issuer_equals_label_issuer # unused function (onetimepass/otpauth/schemas.py:135)
Loading