Skip to content

Commit

Permalink
black 24.1.1 formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-tz committed Jan 30, 2024
1 parent 396ae57 commit 26f6a4f
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 15 deletions.
3 changes: 1 addition & 2 deletions capa/features/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

class Address(abc.ABC):
@abc.abstractmethod
def __eq__(self, other):
...
def __eq__(self, other): ...

@abc.abstractmethod
def __lt__(self, other):
Expand Down
1 change: 1 addition & 0 deletions capa/features/freeze/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
"""

import json
import zlib
import logging
Expand Down
6 changes: 3 additions & 3 deletions capa/ida/plugin/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,9 +932,9 @@ def get_ask_use_persistent_cache(self, analyze):
update_wait_box("verifying cached results")

try:
results: Optional[
capa.render.result_document.ResultDocument
] = capa.ida.helpers.load_and_verify_cached_results()
results: Optional[capa.render.result_document.ResultDocument] = (
capa.ida.helpers.load_and_verify_cached_results()
)
except Exception as e:
capa.ida.helpers.inform_user_ida_ui("Failed to verify cached results, reanalyzing program")
logger.exception("Failed to verify cached results (error: %s)", e)
Expand Down
8 changes: 5 additions & 3 deletions capa/ida/plugin/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,11 @@ def load_preview_meta(self, ea, author, scope):
" references:",
" - <insert_references>",
" examples:",
f" - {capa.ida.helpers.get_file_md5().upper()}:{hex(ea)}"
if ea
else f" - {capa.ida.helpers.get_file_md5().upper()}",
(
f" - {capa.ida.helpers.get_file_md5().upper()}:{hex(ea)}"
if ea
else f" - {capa.ida.helpers.get_file_md5().upper()}"
),
" features:",
]
self.setText("\n".join(metadata_default))
Expand Down
4 changes: 2 additions & 2 deletions capa/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ def result_rec(result: capa.features.common.Result):
)
for t in threads
if t in matched_threads
) # this object is open to extension in the future,
), # this object is open to extension in the future,
# such as with the function name, etc.
)
for p, threads in threads_by_process.items()
Expand Down Expand Up @@ -524,7 +524,7 @@ def compute_static_layout(rules: RuleSet, extractor: StaticFeatureExtractor, cap
address=frz.Address.from_capa(f),
matched_basic_blocks=tuple(
rdoc.BasicBlockLayout(address=frz.Address.from_capa(bb)) for bb in bbs if bb in matched_bbs
) # this object is open to extension in the future,
), # this object is open to extension in the future,
# such as with the function name, etc.
)
for f, bbs in bbs_by_function.items()
Expand Down
9 changes: 4 additions & 5 deletions capa/render/result_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ class CompoundStatementType:
OPTIONAL = "optional"


class StatementModel(FrozenModel):
...
class StatementModel(FrozenModel): ...


class CompoundStatement(StatementModel):
Expand Down Expand Up @@ -650,9 +649,9 @@ def from_capa(cls, meta: Metadata, rules: RuleSet, capabilities: MatchResults) -
return ResultDocument(meta=meta, rules=rule_matches)

def to_capa(self) -> Tuple[Metadata, Dict]:
capabilities: Dict[
str, List[Tuple[capa.features.address.Address, capa.features.common.Result]]
] = collections.defaultdict(list)
capabilities: Dict[str, List[Tuple[capa.features.address.Address, capa.features.common.Result]]] = (
collections.defaultdict(list)
)

# this doesn't quite work because we don't have the rule source for rules that aren't matched.
rules_by_name = {
Expand Down
1 change: 1 addition & 0 deletions capa/render/verbose.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
"""

from typing import cast

import tabulate
Expand Down
1 change: 1 addition & 0 deletions scripts/cache-ruleset.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
"""

import sys
import logging
import argparse
Expand Down
1 change: 1 addition & 0 deletions scripts/capafmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
"""

import sys
import logging
import argparse
Expand Down
1 change: 1 addition & 0 deletions scripts/import-to-ida.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
"""

import logging
import binascii
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions scripts/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
"""

import gc
import os
import re
Expand Down

0 comments on commit 26f6a4f

Please sign in to comment.