diff --git a/README.md b/README.md index f462a42..5a8dc96 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -

diff --git a/docs/core.rst b/docs/core.rst index d9d7cb0..e6545e5 100644 --- a/docs/core.rst +++ b/docs/core.rst @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - Core ==== diff --git a/docs/helpers.rst b/docs/helpers.rst index 530e036..e8192e1 100644 --- a/docs/helpers.rst +++ b/docs/helpers.rst @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - Helpers ======= diff --git a/docs/index.rst b/docs/index.rst index 0369d6f..d04eaf0 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - UCloud SDK Python 2 =================== diff --git a/docs/quick_start.rst b/docs/quick_start.rst index 0db589a..bfc0176 100644 --- a/docs/quick_start.rst +++ b/docs/quick_start.rst @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - QuickStart ========== diff --git a/docs/services.rst b/docs/services.rst index 446e90a..0eca26a 100644 --- a/docs/services.rst +++ b/docs/services.rst @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - UCloud SDK Services =================== diff --git a/docs/usage.rst b/docs/usage.rst index 4a922f3..04986e5 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - Usage ===== diff --git a/examples/two-tier/README.md b/examples/two-tier/README.md index 1a3c645..371c7d4 100644 --- a/examples/two-tier/README.md +++ b/examples/two-tier/README.md @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - # UCloud SDK Two-Tier Example ## What is the goal diff --git a/examples/uhost/README.md b/examples/uhost/README.md index 08b363e..9aabc7e 100644 --- a/examples/uhost/README.md +++ b/examples/uhost/README.md @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - # UCloud SDK UHost Example ## What is the goal diff --git a/scripts/migrate/_migrate.py b/scripts/migrate/_migrate.py index b2e8ac2..ae1c805 100644 --- a/scripts/migrate/_migrate.py +++ b/scripts/migrate/_migrate.py @@ -25,8 +25,6 @@ class Config: class Migrate(object): - UTF8_HEADER = '# -*- coding: utf-8 -*-\n\n' - default_plugins_classes = { "py3to2": SDK3to2Transformer, "doc": DocTransformer, @@ -79,7 +77,7 @@ def run(self, source_path: str, output_path: str): # convert destination code output_code = source_code for plugin in plugins: - output_code = self.UTF8_HEADER + plugin.convert(source_code) + output_code = plugin.convert(source_code) # output to file os.makedirs(os.path.dirname(result_path), exist_ok=True) diff --git a/scripts/migrate/_plugin_py3to2.py b/scripts/migrate/_plugin_py3to2.py index 4f3e424..1dece89 100644 --- a/scripts/migrate/_plugin_py3to2.py +++ b/scripts/migrate/_plugin_py3to2.py @@ -4,6 +4,8 @@ class SDK3to2Transformer(ast.NodeTransformer): + UTF8_HEADER = '# -*- coding: utf-8 -*-\n\n' + def visit_Import(self, node): is_typing = [alias for alias in node.names if alias.name == 'typing'] return None if is_typing else node @@ -56,4 +58,4 @@ def visit_ClassDef(self, node): def convert(self, source: str) -> str: ast_node = ast.parse(source) ast_node = self.visit(ast_node) - return astor.to_source(ast_node) + return self.UTF8_HEADER + astor.to_source(ast_node) diff --git a/tests/test_testing/test_utest.py b/tests/test_testing/test_utest.py index a75429f..858cdaf 100644 --- a/tests/test_testing/test_utest.py +++ b/tests/test_testing/test_utest.py @@ -5,7 +5,7 @@ @pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) -def test_acc_pre_check(client): +def test_acc_pre_check(self, client): assert str(client) assert client.config.to_dict() assert client.credential.to_dict() diff --git a/ucloud/core/utils/compat.py b/ucloud/core/utils/compat.py index 33e9dbc..443799e 100644 --- a/ucloud/core/utils/compat.py +++ b/ucloud/core/utils/compat.py @@ -10,6 +10,6 @@ else: import types - str = unicode + str = unicode # noqa: F821 string_types = types.StringTypes from collections import Callable